Make cocoa opengl backend threadsafe.
authorGunnar Sletta <gunnar.sletta@nokia.com>
Thu, 24 Nov 2011 15:38:40 +0000 (16:38 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 25 Nov 2011 08:54:38 +0000 (09:54 +0100)
The current implementation on Mac OS X called update() inside
the cocoa plugin from the GUI thread, which breaks when trying
to use the GL context from another thread and the window gets
resized. We now only call it from makeCurrent()

Change-Id: I025aad3a3b140e85e729816bf3b68827337cc80d
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/cocoa/qcocoaglcontext.mm
src/plugins/platforms/cocoa/qcocoawindow.mm

index bc9f55d..2b21f08 100644 (file)
@@ -86,6 +86,7 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
     setActiveWindow(window);
 
     [m_context makeCurrentContext];
+    update();
     return true;
 }
 
index aef9750..9caade6 100644 (file)
@@ -125,9 +125,6 @@ void QCocoaWindow::setGeometry(const QRect &rect)
     [[m_nsWindow contentView] setFrameSize:bounds.size];
     [m_nsWindow setContentSize : bounds.size];
     [m_nsWindow setFrameOrigin : bounds.origin];
-
-    if (m_glContext)
-        m_glContext->update();
 }
 
 void QCocoaWindow::setVisible(bool visible)
@@ -215,9 +212,6 @@ NSView *QCocoaWindow::contentView() const
 
 void QCocoaWindow::windowDidMove()
 {
-    if (m_glContext)
-        m_glContext->update();
-
     NSRect rect = [[m_nsWindow contentView]frame];
     NSRect windowRect = [m_nsWindow frame];
 
@@ -228,9 +222,6 @@ void QCocoaWindow::windowDidMove()
 
 void QCocoaWindow::windowDidResize()
 {
-    if (m_glContext)
-        m_glContext->update();
-
     NSRect rect = [[m_nsWindow contentView]frame];
     NSRect windowRect = [m_nsWindow frame];