diff --git a/src/core/qmlglobal.cpp b/src/core/qmlglobal.cpp index 0bee3142..9049e7a6 100644 --- a/src/core/qmlglobal.cpp +++ b/src/core/qmlglobal.cpp @@ -127,8 +127,10 @@ void QuickshellTracked::updateScreens() { next:; } + // Retain removed screens rather than deleting them, since users might hold on to + // a bare `QObject*` (via a `QVariant`) pointing at the old screen. for (auto* oldScreen: this->screens) { - oldScreen->deleteLater(); + this->mDeadScreens.push_back(oldScreen); } this->screens = newScreens; diff --git a/src/core/qmlglobal.hpp b/src/core/qmlglobal.hpp index 2887a935..fce8abd9 100644 --- a/src/core/qmlglobal.hpp +++ b/src/core/qmlglobal.hpp @@ -77,6 +77,11 @@ private slots: signals: void screensChanged(); + +private: + // Screens removed from the system are stored here instead of being + // deleted, since users might hold on to bare `QObject*`s pointing at them. + QVector mDeadScreens; }; class QuickshellGlobal: public QObject {