@@ -151,6 +151,7 @@ void ProxyWindowBase::completeWindow() {
151151 this ->window ->setScreen (this ->mScreen );
152152 } else if (this ->mScreen == nullptr ) {
153153 this ->mScreen = this ->window ->screen ();
154+ QObject::connect (this ->mScreen , &QObject::destroyed, this , &ProxyWindowBase::onScreenDestroyed);
154155 }
155156
156157 this ->setWidth (this ->mWidth );
@@ -267,15 +268,11 @@ void ProxyWindowBase::setHeight(qint32 height) {
267268}
268269
269270void ProxyWindowBase::setScreen (QuickshellScreenInfo* screen) {
270- if (this ->mScreen != nullptr ) {
271- QObject::disconnect (this ->mScreen , nullptr , this , nullptr );
272- }
273-
274271 auto * qscreen = screen == nullptr ? nullptr : screen->screen ;
275272 if (qscreen == this ->mScreen ) return ;
276273
277- if (qscreen != nullptr ) {
278- QObject::connect (qscreen, &QObject::destroyed , this , &ProxyWindowBase::onScreenDestroyed );
274+ if (this -> mScreen != nullptr ) {
275+ QObject::disconnect ( this -> mScreen , nullptr , this , nullptr );
279276 }
280277
281278 if (this ->window == nullptr ) {
@@ -289,6 +286,8 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
289286
290287 if (qscreen) this ->mScreen = qscreen;
291288 else this ->mScreen = this ->window ->screen ();
289+
290+ QObject::connect (this ->mScreen , &QObject::destroyed, this , &ProxyWindowBase::onScreenDestroyed);
292291}
293292
294293void ProxyWindowBase::onScreenDestroyed () { this ->mScreen = nullptr ; }
0 commit comments