Fix Invalid Drawable error for QGLWidget on Mac
You are not supposed to call NSOpenGLContext -setView: for a view that has not yet called drawRect. We we attempted to do this, we would get the invalid drawable error, leading to QGLWidgets just drawing garbage. Task-number: QTBUG-28175 Change-Id: I47aef07b4676f2db8591f98fc1661f6f447bdef9 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
074975055d
commit
cd2a51a66f
@ -69,6 +69,9 @@ QT_END_NAMESPACE
|
||||
bool m_sendUpAsRightButton;
|
||||
Qt::KeyboardModifiers currentWheelModifiers;
|
||||
bool m_subscribesForGlobalFrameNotifications;
|
||||
QCocoaGLContext *m_glContext;
|
||||
bool m_glContextDirty;
|
||||
bool m_drawRectHasBeenCalled;
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
|
@ -85,6 +85,9 @@ static QTouchDevice *touchDevice = 0;
|
||||
m_buttons = Qt::NoButton;
|
||||
m_sendKeyEvent = false;
|
||||
m_subscribesForGlobalFrameNotifications = false;
|
||||
m_glContext = 0;
|
||||
m_glContextDirty = false;
|
||||
m_drawRectHasBeenCalled = false;
|
||||
currentCustomDragTypes = 0;
|
||||
m_sendUpAsRightButton = false;
|
||||
|
||||
@ -150,7 +153,12 @@ static QTouchDevice *touchDevice = 0;
|
||||
|
||||
- (void) setQCocoaGLContext:(QCocoaGLContext *)context
|
||||
{
|
||||
[context->nsOpenGLContext() setView:self];
|
||||
m_glContext = context;
|
||||
if (m_drawRectHasBeenCalled) {
|
||||
[m_glContext->nsOpenGLContext() setView:self];
|
||||
} else {
|
||||
m_glContextDirty = true;
|
||||
}
|
||||
if (!m_subscribesForGlobalFrameNotifications) {
|
||||
// NSOpenGLContext expects us to repaint (or update) the view when
|
||||
// it changes position on screen. Since this happens unnoticed for
|
||||
@ -344,6 +352,13 @@ static QTouchDevice *touchDevice = 0;
|
||||
|
||||
- (void) drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
if (m_glContext && m_glContextDirty) {
|
||||
[m_glContext->nsOpenGLContext() setView:self];
|
||||
m_glContextDirty = false;
|
||||
} else {
|
||||
m_drawRectHasBeenCalled = true;
|
||||
}
|
||||
|
||||
if (!m_backingStore)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user