Fix bug in UI and OpenGL thread communication