Patch from https://codereview.qt-project.org/#change,84975