Similar to https://qt-project.atlassian.net/browse/QTBUG-137440
To fix https://bugs.kde.org/show_bug.cgi?id=512867
I'll admit I don't quite know what I'm doing here, I'm mostly guessing and mimicking, but it does seem to remove the nondeterminism :)
Inspired in part by plasma-workspace!6075 (diffs)