diff options
author | Thomas Senyk <thomas.senyk@qt.io> | 2023-10-09 15:39:24 +0200 |
---|---|---|
committer | Thomas Senyk <thomas.senyk@qt.io> | 2023-10-10 14:44:38 +0200 |
commit | eb1a83ea9bb145d72a23f925002c9e9a745c110e (patch) | |
tree | 6a288ebf19bf6e1a101a750c55c08e4b9d802df9 /src/compositor | |
parent | ce76cf8e97713093d8cea781e192d1e5d2ed5afe (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
Pick-to: 6.6
Change-Id: I870e92b448dfd1f9864ff94743cf7accc50fc6ff
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/compositor')
-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); |