From c0847366ddfd85212a049d611ec7628611091be1 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 7 Apr 2024 14:17:57 -0700 Subject: [PATCH] core/window: fix reloads breaking for indirect window children --- src/core/proxywindow.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/proxywindow.cpp b/src/core/proxywindow.cpp index 7756e2d..17473dc 100644 --- a/src/core/proxywindow.cpp +++ b/src/core/proxywindow.cpp @@ -17,6 +17,7 @@ #include "qmlscreen.hpp" #include "region.hpp" #include "reload.hpp" +#include "windowinterface.hpp" ProxyWindowBase::ProxyWindowBase(QObject* parent) : Reloadable(parent) @@ -47,7 +48,20 @@ void ProxyWindowBase::onReload(QObject* oldInstance) { auto wasVisible = this->window != nullptr && this->window->isVisible(); if (this->window == nullptr) this->window = new QQuickWindow(); - Reloadable::reloadRecursive(this->mContentItem, oldInstance); + // The qml engine will leave the WindowInterface as owner of everything + // nested in an item, so we have to make sure the interface's children + // are also reloaded. + // Reparenting from the interface does not work reliably, so instead + // we check if the parent is one, as it proxies reloads to here. + if (auto* w = qobject_cast(this->parent())) { + for (auto* child: w->children()) { + if (child == this) continue; + auto* oldInterfaceParent = oldInstance == nullptr ? nullptr : oldInstance->parent(); + Reloadable::reloadRecursive(child, oldInterfaceParent); + } + } + + Reloadable::reloadChildrenRecursive(this, oldInstance); this->connectWindow(); this->completeWindow();