summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorAndy Nichols <nezticle@gmail.com>2013-05-14 13:57:15 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-14 14:45:13 +0200
commit27cbb58a92aaa629869f5b4dd05f2cefb4fc9f3a (patch)
tree28be08a2841e66875c1a75ad20f137e0be1ee062 /src/plugins/platforms/cocoa
parent32f09caa35b77d9262e186f1fc66edf2ed3fe7d6 (diff)
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 <liang.qi@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h3
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm18
2 files changed, 9 insertions, 12 deletions
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)