From 12f8b583cfd083f52b95248a798184f43314955a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 12 Jul 2022 19:43:47 +0200 Subject: [PATCH] QOpenGLContext: de-inline virtual dtors of private classes ... pinning the vtables to a single TU instead of duplicating them for every user. Pick-to: 6.4 Task-number: QTBUG-45582 Change-Id: I728a5c47edaafe7ef4fdca1db8d0247ed4be9713 Reviewed-by: Fabian Kosmale --- src/gui/kernel/qopenglcontext.cpp | 18 ++++++++++++++++++ src/gui/kernel/qopenglcontext_p.h | 12 ++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 5849c7318e..99c13257a3 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -360,6 +360,14 @@ bool QOpenGLContext::create() return isValid(); } +QOpenGLContextPrivate::~QOpenGLContextPrivate() +{ + //do not delete the QOpenGLContext handle here as it is deleted in + //QWidgetPrivate::deleteTLSysExtra() + + delete versionFunctions; +} + void QOpenGLContextPrivate::adopt(QPlatformOpenGLContext *context) { Q_Q(QOpenGLContext); @@ -995,6 +1003,9 @@ QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup() return current ? current->shareGroup() : nullptr; } +QOpenGLContextGroupPrivate::~QOpenGLContextGroupPrivate() + = default; + void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx) { const auto locker = qt_scoped_lock(m_mutex); @@ -1136,6 +1147,10 @@ void QOpenGLSharedResource::free() \inmodule QtGui */ + +QOpenGLSharedResourceGuard::~QOpenGLSharedResourceGuard() + = default; + void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context) { if (m_id) { @@ -1235,6 +1250,9 @@ void QOpenGLMultiGroupSharedResource::cleanup(QOpenGLContextGroup *group, QOpenG m_groups.removeOne(group); } +QOpenGLContextVersionFunctionHelper::~QOpenGLContextVersionFunctionHelper() + = default; + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QOpenGLContext *ctx) { diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index c0ceb682ce..a0e8eda679 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -74,6 +74,7 @@ public: , m_func(func) { } + ~QOpenGLSharedResourceGuard() override; GLuint id() const { return m_id; } @@ -99,6 +100,7 @@ public: , m_refs(0) { } + ~QOpenGLContextGroupPrivate() override; void addContext(QOpenGLContext *ctx); void removeContext(QOpenGLContext *ctx); @@ -160,7 +162,7 @@ class QOpenGLVertexArrayObjectHelper; class Q_GUI_EXPORT QOpenGLContextVersionFunctionHelper { public: - virtual ~QOpenGLContextVersionFunctionHelper() {} + virtual ~QOpenGLContextVersionFunctionHelper(); }; class Q_GUI_EXPORT QOpenGLContextPrivate : public QObjectPrivate @@ -190,13 +192,7 @@ public: requestedFormat = QSurfaceFormat::defaultFormat(); } - ~QOpenGLContextPrivate() - { - //do not delete the QOpenGLContext handle here as it is deleted in - //QWidgetPrivate::deleteTLSysExtra() - - delete versionFunctions; - } + ~QOpenGLContextPrivate() override; void adopt(QPlatformOpenGLContext *);