Backport 3459 stable5

This is the long requested backport of #3459 ti stable5.

Please pull in the stable5 branch of 3rdparty

@FlorinPeter @icewind1991 @butonic @karlitschek THX