From 2f57263c413021716397841ca9d0bfc9628c8703 Mon Sep 17 00:00:00 2001
From: SineStriker <trueful@163.com>
Date: 周三, 06 12月 2023 18:28:52 +0800
Subject: [PATCH] Revert "update pointer usage"

---
 src/core/corewindowagent.cpp |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/core/corewindowagent.cpp b/src/core/corewindowagent.cpp
index 5d1f74e..bea2239 100644
--- a/src/core/corewindowagent.cpp
+++ b/src/core/corewindowagent.cpp
@@ -16,30 +16,23 @@
     CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
     }
 
-    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() {
-        if (context) {
-            delete context;
-            context = nullptr;
-        }
-    }
+    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
 
     void CoreWindowAgentPrivate::init() {
     }
 
-    bool CoreWindowAgentPrivate::setup(const QObject *host, const WindowItemDelegate *delegate) {
+    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
         auto ctx =
 #ifdef Q_OS_WINDOWS
-            new Win32WindowContext(host, delegate)
+            std::make_unique<Win32WindowContext>(host, delegate)
 #else
-            new QtWindowContext(host, window, delegate)
+            std::make_unique<QtWindowContext>(host, window, delegate)
 #endif
             ;
         if (!ctx->setup()) {
-            delete ctx;
-            ctx = nullptr;
             return false;
         }
-        context = ctx;
+        context = std::move(ctx);
         return true;
     }
 

--
Gitblit v1.9.1