From 8f9fa232ac72a5f0caf58e120f3825820423c4de Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Tue, 6 Dec 2022 13:32:42 +0100 Subject: Compositor_api: delete TexProvider properly If a QuickItem used in a compositor has a texture provider, it is not destroyed before deleting QRhi. It makes a warning of unreleased resources. Fixes: QTBUG-108767 Pick-to: 6.4 Change-Id: Id86839f1de1ff4f374170627d9c1e02c4afb7301 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../compositor_api/qwaylandquickitem.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp') diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index eb2412052..3f729e9f1 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -475,8 +475,10 @@ QWaylandQuickItem::~QWaylandQuickItem() Q_D(QWaylandQuickItem); disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow); QMutexLocker locker(d->mutex); - if (d->provider) + if (d->provider) { + disconnect(d->texProviderConnection); d->provider->deleteLater(); + } } /*! @@ -1478,8 +1480,24 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat d->newTexture = true; } - if (!d->provider) + if (!d->provider) { d->provider = new QWaylandSurfaceTextureProvider(); + if (compositor()) { + d->texProviderConnection = + QObject::connect( + compositor(), + &QObject::destroyed, + this, + [this](QObject*) { + auto *itemPriv = QWaylandQuickItemPrivate::get(this); + if (itemPriv->provider) { + itemPriv->provider->deleteLater(); + itemPriv->provider = nullptr; + } + disconnect(itemPriv->texProviderConnection); } + ); + } + } if (d->newTexture) { d->newTexture = false; -- cgit v1.2.3