Fix for issue #2815 (pull request for 2.4 branch)