Skip to content

Commit 611cd76

Browse files
committed
core/proxywindow: connect mScreen's destroy signal in all cases
Fixes edge case crashes when unplugging and replugging monitors.
1 parent 27840db commit 611cd76

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/window/proxywindow.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

269270
void 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

294293
void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }

0 commit comments

Comments
 (0)