From 07edbd23ed774c4f0331bb92d35add77fe91769c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 4 Jan 2012 14:17:45 +0100 Subject: Introduced QOpenGLContext::aboutToBeDestroyed() signal. This signal can be used to clean up OpenGL resources in a safe way before the context is destroyed. Task-number: QTBUG-20083 Change-Id: I45a4be01b06af4ee7196fa502116f099d50afeab Reviewed-by: Gunnar Sletta --- src/gui/kernel/qopenglcontext.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gui/kernel/qopenglcontext.cpp') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 6a9cb430288..29a9e92e5ca 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) @@ -185,6 +187,17 @@ void QOpenGLContext::destroy() d->functions = 0; } +/*! + \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 */ -- cgit v1.2.3