fix(wayland): layershell windows are recreated if attach fails

Usually this happens if the namespace changes
This commit is contained in:
outfoxxed 2024-02-25 16:13:24 -08:00
parent c2930783ea
commit 13c5d7c7a9
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
5 changed files with 41 additions and 13 deletions

View file

@ -28,14 +28,7 @@ ProxyWindowBase::~ProxyWindowBase() {
}
void ProxyWindowBase::onReload(QObject* oldInstance) {
auto* old = qobject_cast<ProxyWindowBase*>(oldInstance);
if (old == nullptr || old->window == nullptr) {
this->window = new QQuickWindow();
} else {
this->window = old->disownWindow();
}
this->window = this->createWindow(oldInstance);
this->setupWindow();
Reloadable::reloadRecursive(this->mContentItem, oldInstance);
@ -52,6 +45,16 @@ void ProxyWindowBase::onReload(QObject* oldInstance) {
this->window->setVisible(this->mVisible);
}
QQuickWindow* ProxyWindowBase::createWindow(QObject* oldInstance) {
auto* old = qobject_cast<ProxyWindowBase*>(oldInstance);
if (old == nullptr || old->window == nullptr) {
return new QQuickWindow();
} else {
return old->disownWindow();
}
}
void ProxyWindowBase::setupWindow() {
// clang-format off
QObject::connect(this->window, &QWindow::visibilityChanged, this, &ProxyWindowBase::visibleChanged);