From 0287f19b3eabf6b6632d51c0288e6cf0be2c5e69 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <zhaoyuhang@rankyee.com> Date: 周三, 06 12月 2023 18:04:31 +0800 Subject: [PATCH] update pointer usage --- src/core/corewindowagent.cpp | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/corewindowagent.cpp b/src/core/corewindowagent.cpp index bea2239..5d1f74e 100644 --- a/src/core/corewindowagent.cpp +++ b/src/core/corewindowagent.cpp @@ -16,23 +16,30 @@ CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) { } - CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default; + CoreWindowAgentPrivate::~CoreWindowAgentPrivate() { + if (context) { + delete context; + context = nullptr; + } + } void CoreWindowAgentPrivate::init() { } - bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) { + bool CoreWindowAgentPrivate::setup(const QObject *host, const WindowItemDelegate *delegate) { auto ctx = #ifdef Q_OS_WINDOWS - std::make_unique<Win32WindowContext>(host, delegate) + new Win32WindowContext(host, delegate) #else - std::make_unique<QtWindowContext>(host, window, delegate) + new QtWindowContext(host, window, delegate) #endif ; if (!ctx->setup()) { + delete ctx; + ctx = nullptr; return false; } - context = std::move(ctx); + context = ctx; return true; } -- Gitblit v1.9.1