Use itemChange instead of a connect to windowChanged

with itemChange watching SceneChange is more efficient than connecting
to the windowChanged signal, also this won't arrive during teardown,
aoiding the "destructor already ran" assert.
This commit is contained in:
Marco Martin 2023-10-18 14:39:58 +02:00
parent c0cc162ba6
commit e67847d43f
2 changed files with 9 additions and 2 deletions

View file

@ -106,8 +106,6 @@ WindowThumbnailItem::WindowThumbnailItem(QQuickItem *parent)
this, &WindowThumbnailItem::destroyOffscreenTexture); this, &WindowThumbnailItem::destroyOffscreenTexture);
connect(Compositor::self(), &Compositor::compositingToggled, connect(Compositor::self(), &Compositor::compositingToggled,
this, &WindowThumbnailItem::updateFrameRenderingConnection); this, &WindowThumbnailItem::updateFrameRenderingConnection);
connect(this, &QQuickItem::windowChanged,
this, &WindowThumbnailItem::updateFrameRenderingConnection);
} }
WindowThumbnailItem::~WindowThumbnailItem() WindowThumbnailItem::~WindowThumbnailItem()
@ -133,6 +131,14 @@ void WindowThumbnailItem::releaseResources()
} }
} }
void WindowThumbnailItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value)
{
if (change == QQuickItem::ItemSceneChange) {
updateFrameRenderingConnection();
}
QQuickItem::itemChange(change, value);
}
bool WindowThumbnailItem::isTextureProvider() const bool WindowThumbnailItem::isTextureProvider() const
{ {
return true; return true;

View file

@ -45,6 +45,7 @@ public:
protected: protected:
void releaseResources() override; void releaseResources() override;
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
Q_SIGNALS: Q_SIGNALS:
void wIdChanged(); void wIdChanged();