Fix threading for Qt5.

Fix GL Context on Qt5.
Also fix EmuThread loop.

Working fine on Linux.
The lock would end before the condition is checked.