From 6367b56f5548a86e9b541f871870a3bb1dc69392 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 18 Jul 2024 01:57:40 -0700 Subject: [PATCH] core/window: fix attached property prior to backer creation --- src/core/proxywindow.cpp | 3 +-- src/core/windowinterface.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/core/proxywindow.cpp b/src/core/proxywindow.cpp index 8f8ab0dc..05fbff0a 100644 --- a/src/core/proxywindow.cpp +++ b/src/core/proxywindow.cpp @@ -26,6 +26,7 @@ ProxyWindowBase::ProxyWindowBase(QObject* parent) , mContentItem(new QQuickItem()) { QQmlEngine::setObjectOwnership(this->mContentItem, QQmlEngine::CppOwnership); this->mContentItem->setParent(this); + this->mContentItem->setProperty("__qs_proxywindow", QVariant::fromValue(this)); // clang-format off QObject::connect(this, &ProxyWindowBase::widthChanged, this, &ProxyWindowBase::onWidthChanged); @@ -124,8 +125,6 @@ void ProxyWindowBase::connectWindow() { generation->registerIncubationController(this->window->incubationController()); } - this->window->setProperty("__qs_proxywindow", QVariant::fromValue(this)); - // clang-format off QObject::connect(this->window, &QWindow::visibilityChanged, this, &ProxyWindowBase::visibleChanged); QObject::connect(this->window, &QWindow::xChanged, this, &ProxyWindowBase::xChanged); diff --git a/src/core/windowinterface.cpp b/src/core/windowinterface.cpp index 48f6f2ae..d941d0ec 100644 --- a/src/core/windowinterface.cpp +++ b/src/core/windowinterface.cpp @@ -7,11 +7,16 @@ #include "proxywindow.hpp" QsWindowAttached* WindowInterface::qmlAttachedProperties(QObject* object) { - auto* item = qobject_cast(object); - if (!item) return nullptr; - auto* window = item->window(); - if (!window) return nullptr; - auto* proxy = window->property("__qs_proxywindow").value(); + auto* visualRoot = qobject_cast(object); + + ProxyWindowBase* proxy = nullptr; + while (visualRoot != nullptr) { + proxy = visualRoot->property("__qs_proxywindow").value(); + + if (proxy) break; + visualRoot = visualRoot->parentItem(); + }; + if (!proxy) return nullptr; auto v = proxy->property("__qs_window_attached");