Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: memory leak #418

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/dquickwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ DQuickWindowAttachedPrivate::DQuickWindowAttachedPrivate(QWindow *window, DQuick
: DObjectPrivate(qq)
, window(window)
, wmWindowTypes(DWindowManagerHelper::UnknowWindowType)
, appLoaderItem(new DQuickAppLoaderItem())
, appLoaderItem(nullptr)
{
}

Expand Down Expand Up @@ -482,6 +482,10 @@ QQmlComponent *DQuickWindowAttached::loadingOverlay() const
DQuickAppLoaderItem *DQuickWindowAttached::appLoader() const
{
D_DC(DQuickWindowAttached);
if (!d->appLoaderItem) {
const_cast<DQuickWindowAttachedPrivate *>(d)->appLoaderItem =
new DQuickAppLoaderItem(window()->contentItem());
}
return d->appLoaderItem;
}

Expand All @@ -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();
}
Expand Down
6 changes: 4 additions & 2 deletions src/private/dquickcontrolpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ class Q_DECL_HIDDEN CustomMetaObject : public QQmlOpenMetaObject

}

~CustomMetaObject()
~CustomMetaObject() override
{

if (auto item = type()) {
item->release();
}
}

inline DQuickControlColorSelector *owner() const {
Expand Down
Loading