Fix #5051
Merge pull request #5094 from ivarne/issue-5051

Fix #5051