diff options
author | Thomas Senyk <thomas.senyk@qt.io> | 2023-10-09 15:39:24 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-10-10 13:55:18 +0000 |
commit | 251202732436aa958186948d8a06506c5c8ab8c5 (patch) | |
tree | 74de73b6d18ffbe085474688708606d55fa2ace4 /src | |
parent | aa9d32b3257b48c5d84e3e84f4f2607068a38f30 (diff) |
Fix regression in orphaned texture clean-up
The recently refactored QWaylandTextureOrphanage
used sender() in a DirectionConnection,
which doesn't work if sender and receiver live in
different threads - which happens if multiple windows
(and therefor multiple QSGRenderThread) exist
This patch fixed that by replacing sender()
with a lambda capture
Also: fix a weirdly phrased comment
Fixes: QTBUG-117932
Change-Id: I870e92b448dfd1f9864ff94743cf7accc50fc6ff
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit eb1a83ea9bb145d72a23f925002c9e9a745c110e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/compositor/hardware_integration/qwltextureorphanage.cpp | 10 | ||||
-rw-r--r-- | src/compositor/hardware_integration/qwltextureorphanage_p.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/compositor/hardware_integration/qwltextureorphanage.cpp b/src/compositor/hardware_integration/qwltextureorphanage.cpp index c1337190a..c1ff86977 100644 --- a/src/compositor/hardware_integration/qwltextureorphanage.cpp +++ b/src/compositor/hardware_integration/qwltextureorphanage.cpp @@ -42,8 +42,8 @@ void QWaylandTextureOrphanage::admitTexture(QOpenGLTexture *tex, QOpenGLContext } connect(ctx, &QOpenGLContext::aboutToBeDestroyed, this, - &QWaylandTextureOrphanage::onContextAboutToBeDestroyed, - Qt::ConnectionType(Qt::DirectConnection | Qt::UniqueConnection)); + [this, ctx]() { this->onContextAboutToBeDestroyed(ctx); }, + Qt::ConnectionType(Qt::DirectConnection)); } void QWaylandTextureOrphanage::deleteTextures() @@ -71,9 +71,8 @@ void QWaylandTextureOrphanage::deleteTextures() } } -void QWaylandTextureOrphanage::onContextAboutToBeDestroyed() +void QWaylandTextureOrphanage::onContextAboutToBeDestroyed(QOpenGLContext *ctx) { - QOpenGLContext *ctx = qobject_cast<QOpenGLContext *>(sender()); Q_ASSERT(ctx != nullptr); qCDebug(qLcWTO) << Q_FUNC_INFO << " ctx (" << ctx @@ -89,7 +88,8 @@ void QWaylandTextureOrphanage::deleteTexturesByContext(QOpenGLContext *ctx) { // NOTE: We are (by class-internal design) locked (m_containerLock) // when we enter this function! - // So in a debug-build we will fail below: + // If not (e.g.: someone changes something in/around this class), + // then in a debug-build we will fail below: Q_ASSERT(!m_containerLock.tryLock()); QList<QOpenGLTexture *> texturesToDelete = m_orphanedTextures.values(ctx); diff --git a/src/compositor/hardware_integration/qwltextureorphanage_p.h b/src/compositor/hardware_integration/qwltextureorphanage_p.h index d267043e4..1e5298530 100644 --- a/src/compositor/hardware_integration/qwltextureorphanage_p.h +++ b/src/compositor/hardware_integration/qwltextureorphanage_p.h @@ -47,7 +47,7 @@ public: public slots: // uses sender() to call deleteTexturesByContext - void onContextAboutToBeDestroyed(); + void onContextAboutToBeDestroyed(QOpenGLContext *ctx); private: void deleteTexturesByContext(QOpenGLContext *ctx); |