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.
wilder/Plasma/6.2
Marco Martin 2 years ago
parent c0cc162ba6
commit e67847d43f
  1. 10
      src/scripting/windowthumbnailitem.cpp
  2. 1
      src/scripting/windowthumbnailitem.h

@ -106,8 +106,6 @@ WindowThumbnailItem::WindowThumbnailItem(QQuickItem *parent)
this, &WindowThumbnailItem::destroyOffscreenTexture);
connect(Compositor::self(), &Compositor::compositingToggled,
this, &WindowThumbnailItem::updateFrameRenderingConnection);
connect(this, &QQuickItem::windowChanged,
this, &WindowThumbnailItem::updateFrameRenderingConnection);
}
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
{
return true;

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

Loading…
Cancel
Save