From 0c185517a6d9a7d2c07ac4fb2e2cbc3a7a7af208 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Wed, 20 Nov 2024 02:02:00 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkdeclarative Synchronize source files from linuxdeepin/dtkdeclarative. Source-pull-request: https://github.com/linuxdeepin/dtkdeclarative/pull/418 --- src/dquickwindow.cpp | 10 ++++++++-- src/private/dquickcontrolpalette.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dquickwindow.cpp b/src/dquickwindow.cpp index 2e48ecd..4412674 100644 --- a/src/dquickwindow.cpp +++ b/src/dquickwindow.cpp @@ -64,7 +64,7 @@ DQuickWindowAttachedPrivate::DQuickWindowAttachedPrivate(QWindow *window, DQuick : DObjectPrivate(qq) , window(window) , wmWindowTypes(DWindowManagerHelper::UnknowWindowType) - , appLoaderItem(new DQuickAppLoaderItem()) + , appLoaderItem(nullptr) { } @@ -482,6 +482,10 @@ QQmlComponent *DQuickWindowAttached::loadingOverlay() const DQuickAppLoaderItem *DQuickWindowAttached::appLoader() const { D_DC(DQuickWindowAttached); + if (!d->appLoaderItem) { + const_cast(d)->appLoaderItem = + new DQuickAppLoaderItem(window()->contentItem()); + } return d->appLoaderItem; } @@ -494,7 +498,9 @@ void DQuickWindowAttached::setAppLoader(DQuickAppLoaderItem *item) // AppLoaderItem 会在窗口加载完毕后进行创建,因此 // 在窗口创建初期,AppLoaderItem 需要指定一个默认 // 值,防止 Qt 在运行时出现警告和报错 - d->appLoaderItem->deleteLater(); + if (d->appLoaderItem) { + d->appLoaderItem->deleteLater(); + } d->appLoaderItem = item; Q_EMIT appLoaderChanged(); } diff --git a/src/private/dquickcontrolpalette.cpp b/src/private/dquickcontrolpalette.cpp index 2fe3e00..fecd530 100644 --- a/src/private/dquickcontrolpalette.cpp +++ b/src/private/dquickcontrolpalette.cpp @@ -190,9 +190,11 @@ class Q_DECL_HIDDEN CustomMetaObject : public QQmlOpenMetaObject } - ~CustomMetaObject() + ~CustomMetaObject() override { - + if (auto item = type()) { + item->release(); + } } inline DQuickControlColorSelector *owner() const {