diff options
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 965c7a5..01974a2 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -272,6 +272,24 @@ QGLWindowSurface::~QGLWindowSurface() delete d_ptr; } +void QGLWindowSurface::deleted(QObject *object) +{ + QWidget *widget = qobject_cast<QWidget *>(object); + if (widget) { + QWidgetPrivate *widgetPrivate = widget->d_func(); + if (widgetPrivate->extraData()) { + union { QGLContext **ctxPtr; void **voidPtr; }; + voidPtr = &widgetPrivate->extraData()->glContext; + int index = d_ptr->contexts.indexOf(ctxPtr); + if (index != -1) { + delete *ctxPtr; + *ctxPtr = 0; + d_ptr->contexts.removeAt(index); + } + } + } +} + void QGLWindowSurface::hijackWindow(QWidget *widget) { QWidgetPrivate *widgetPrivate = widget->d_func(); @@ -288,6 +306,8 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) union { QGLContext **ctxPtr; void **voidPtr; }; + connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(deleted(QObject *))); + voidPtr = &widgetPrivate->extraData()->glContext; d_ptr->contexts << ctxPtr; qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size(); |