From 27cbb58a92aaa629869f5b4dd05f2cefb4fc9f3a Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 14 May 2013 13:57:15 +0200 Subject: Fix breakage of tst_qquickwindow::grab(invisible) Instead of waiting for -drawRect to call -setView on the NSOpenGLContext, we go ahead and attempt to set the context as soon as possible. If it is indeed required that we call -drawRect first then will try to call -setView again during -drawRect with the new NSOpenGLContext. Change-Id: I33d9f2ba241b49e8cfa6c9156dd5bf5e4cc6b164 Reviewed-by: Liang Qi Reviewed-by: Gunnar Sletta --- src/plugins/platforms/cocoa/qnsview.h | 3 +-- src/plugins/platforms/cocoa/qnsview.mm | 18 ++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 20e82940bd..85f72a4dbb 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -70,8 +70,7 @@ QT_END_NAMESPACE Qt::KeyboardModifiers currentWheelModifiers; bool m_subscribesForGlobalFrameNotifications; QCocoaGLContext *m_glContext; - bool m_glContextDirty; - bool m_drawRectHasBeenCalled; + bool m_shouldSetGLContextinDrawRect; } - (id)init; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3fbe06f555..6fd5cf59e1 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -86,8 +86,7 @@ static QTouchDevice *touchDevice = 0; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; m_glContext = 0; - m_glContextDirty = false; - m_drawRectHasBeenCalled = false; + m_shouldSetGLContextinDrawRect = false; currentCustomDragTypes = 0; m_sendUpAsRightButton = false; @@ -154,11 +153,12 @@ static QTouchDevice *touchDevice = 0; - (void) setQCocoaGLContext:(QCocoaGLContext *)context { m_glContext = context; - if (m_drawRectHasBeenCalled) { - [m_glContext->nsOpenGLContext() setView:self]; - } else { - m_glContextDirty = true; + [m_glContext->nsOpenGLContext() setView:self]; + if (![m_glContext->nsOpenGLContext() view]) { + //was unable to set view + m_shouldSetGLContextinDrawRect = true; } + if (!m_subscribesForGlobalFrameNotifications) { // NSOpenGLContext expects us to repaint (or update) the view when // it changes position on screen. Since this happens unnoticed for @@ -352,11 +352,9 @@ static QTouchDevice *touchDevice = 0; - (void) drawRect:(NSRect)dirtyRect { - if (m_glContext && m_glContextDirty) { + if (m_glContext && m_shouldSetGLContextinDrawRect) { [m_glContext->nsOpenGLContext() setView:self]; - m_glContextDirty = false; - } else { - m_drawRectHasBeenCalled = true; + m_shouldSetGLContextinDrawRect = false; } if (!m_backingStore) -- cgit v1.2.3