diff options
Diffstat (limited to 'src/gui/opengl')
-rw-r--r-- | src/gui/opengl/qopengltexture.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglversionfunctions.cpp | 26 | ||||
-rw-r--r-- | src/gui/opengl/qopenglversionfunctions.h | 13 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 13 |
4 files changed, 46 insertions, 8 deletions
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index fa4b6cdab0..9bc9926b70 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -3650,7 +3650,7 @@ QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const } /*! - \enum ComparisonFunction + \enum QOpenGLTexture::ComparisonFunction \since 5.5 This enum specifies which comparison operator is used when texture comparison is enabled on this texture. diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index f3f709c3f0..346a526054 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -67,6 +67,17 @@ void QAbstractOpenGLFunctionsPrivate::removeFunctionsBackend(QOpenGLContext *con context->removeFunctionsBackend(v); } +void QAbstractOpenGLFunctionsPrivate::insertExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f) +{ + Q_ASSERT(context); + context->insertExternalFunctions(f); +} + +void QAbstractOpenGLFunctionsPrivate::removeExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f) +{ + Q_ASSERT(context); + context->removeExternalFunctions(f); +} /*! \class QAbstractOpenGLFunctions @@ -182,6 +193,9 @@ QAbstractOpenGLFunctions::QAbstractOpenGLFunctions() QAbstractOpenGLFunctions::~QAbstractOpenGLFunctions() { + Q_D(QAbstractOpenGLFunctions); + if (d->owningContext) + d->removeExternalFunctions(d->owningContext, this); delete d_ptr; } @@ -191,6 +205,18 @@ bool QAbstractOpenGLFunctions::initializeOpenGLFunctions() { Q_D(QAbstractOpenGLFunctions); d->initialized = true; + + // For a subclass whose instance is not created via + // QOpenGLContext::versionFunctions() owningContext is not set. Set it now + // and register such instances to the context as external ones. These are + // not owned by the context but still need certain cleanup when the context + // is destroyed. + if (!d->owningContext) { + d->owningContext = QOpenGLContext::currentContext(); + if (d->owningContext) + d->insertExternalFunctions(d->owningContext, this); + } + return true; } diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h index 2ae0f429e5..fcf665f97e 100644 --- a/src/gui/opengl/qopenglversionfunctions.h +++ b/src/gui/opengl/qopenglversionfunctions.h @@ -114,6 +114,8 @@ public: QAtomicInt refs; }; +class QAbstractOpenGLFunctions; + class QAbstractOpenGLFunctionsPrivate { public: @@ -128,12 +130,16 @@ public: const QOpenGLVersionStatus &v, QOpenGLVersionFunctionsBackend *backend); static void removeFunctionsBackend(QOpenGLContext *context, const QOpenGLVersionStatus &v); + static void insertExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f); + static void removeExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f); + + static QAbstractOpenGLFunctionsPrivate *get(QAbstractOpenGLFunctions *q); QOpenGLContext *owningContext; bool initialized; }; -class QAbstractOpenGLFunctions +class Q_GUI_EXPORT QAbstractOpenGLFunctions { public: virtual ~QAbstractOpenGLFunctions(); @@ -154,6 +160,11 @@ protected: friend class QOpenGLContext; }; +inline QAbstractOpenGLFunctionsPrivate *QAbstractOpenGLFunctionsPrivate::get(QAbstractOpenGLFunctions *q) +{ + return q->d_func(); +} + #if !defined(QT_OPENGL_ES_2) class QOpenGLFunctions_1_0_CoreBackend : public QOpenGLVersionFunctionsBackend diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 6b0f2fede7..2a1b7f4bf4 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -189,11 +189,16 @@ bool QOpenGLVertexArrayObjectPrivate::create() void QOpenGLVertexArrayObjectPrivate::destroy() { + Q_Q(QOpenGLVertexArrayObject); + + if (context) { + QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + context = 0; + } + if (!vao) return; - Q_Q(QOpenGLVertexArrayObject); - switch (vaoFuncsType) { #ifndef QT_OPENGL_ES_2 case Core_3_2: @@ -212,10 +217,6 @@ void QOpenGLVertexArrayObjectPrivate::destroy() break; } - Q_ASSERT(context); - QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; - vao = 0; } |