summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qopenglcontext.cpp13
-rw-r--r--src/gui/kernel/qopenglcontext.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 6a9cb43028..29a9e92e5c 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -174,6 +174,8 @@ bool QOpenGLContext::create()
void QOpenGLContext::destroy()
{
Q_D(QOpenGLContext);
+ if (d->platformGLContext)
+ emit aboutToBeDestroyed();
if (QOpenGLContext::currentContext() == this)
doneCurrent();
if (d->shareGroup)
@@ -186,6 +188,17 @@ void QOpenGLContext::destroy()
}
/*!
+ \fn void QOpenGLContext::aboutToBeDestroyed()
+
+ This signal is emitted before the underlying native OpenGL context is
+ destroyed, such that users may clean up OpenGL resources that might otherwise
+ be left dangling in the case of shared OpenGL contexts.
+
+ If you wish to make the context current in order to do clean-up, make sure to
+ only connect to the signal using a direct connection.
+*/
+
+/*!
If this is the current context for the thread, doneCurrent is called
*/
QOpenGLContext::~QOpenGLContext()
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index b5a19a0ebc..0d02cfe613 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -118,6 +118,9 @@ public:
QOpenGLFunctions *functions() const;
+Q_SIGNALS:
+ void aboutToBeDestroyed();
+
private:
friend class QGLContext;
friend class QOpenGLContextResourceBase;