Added error checking.
Delayed showing the window until the rendering thread is ready to run.
Removed unnecessary makeCurrent.