From 1408d89b225c822c9aca14bfa12a1ffc6cff722b Mon Sep 17 00:00:00 2001
From: Yuhang Zhao <zhaoyuhang@rankyee.com>
Date: 摹曛, 07 12月 2023 17:43:18 +0800
Subject: [PATCH] remove not needed assert checks

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

diff --git a/src/core/corewindowagent.cpp b/src/core/corewindowagent.cpp
index a4e4ac4..d5dff5a 100644
--- a/src/core/corewindowagent.cpp
+++ b/src/core/corewindowagent.cpp
@@ -1,42 +1,56 @@
 #include "corewindowagent.h"
 #include "corewindowagent_p.h"
 
+#include "qwkcoreglobal_p.h"
+
 #ifdef Q_OS_WINDOWS
-#  include "handler/win32windowcontext_p.h"
+#  include "win32windowcontext_p.h"
 #else
-#  include "handler/qtwindowcontext_p.h"
+#  include "qtwindowcontext_p.h"
 #endif
+
+Q_LOGGING_CATEGORY(qWindowKitLog, "qwindowkit")
 
 namespace QWK {
 
-    CoreWindowAgentPrivate::CoreWindowAgentPrivate() {
+    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
     }
 
-    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() {
-    }
+    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
 
     void CoreWindowAgentPrivate::init() {
     }
 
-    void CoreWindowAgentPrivate::setup(QWindow *window, WindowItemDelegate *delegate) {
+    AbstractWindowContext *CoreWindowAgentPrivate::createContext() const {
+        return
 #ifdef Q_OS_WINDOWS
-        m_eventHandler = new Win32WindowContext(window, delegate);
+            new Win32WindowContext()
 #else
-        m_eventHandler = new QtWindowContext(window, delegate);
+            new QtWindowContext()
 #endif
+                ;
     }
 
-    CoreWindowAgent::~CoreWindowAgent() {
+
+    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
+        std::unique_ptr<AbstractWindowContext> ctx(createContext());
+        if (!ctx->setup(host, delegate)) {
+            return false;
+        }
+        context = std::move(ctx);
+        return true;
     }
+
+    CoreWindowAgent::~CoreWindowAgent() = default;
 
     void CoreWindowAgent::showSystemMenu(const QPoint &pos) {
         Q_D(CoreWindowAgent);
-        d->m_eventHandler->showSystemMenu(pos);
+        d->context->showSystemMenu(pos);
     }
 
     void CoreWindowAgent::startSystemMove(const QPoint &pos) {
         Q_D(CoreWindowAgent);
-        auto win = d->m_eventHandler->window();
+        auto win = d->context->window();
         if (!win) {
             return;
         }
@@ -47,7 +61,7 @@
 
     void CoreWindowAgent::startSystemResize(Qt::Edges edges, const QPoint &pos) {
         Q_D(CoreWindowAgent);
-        auto win = d->m_eventHandler->window();
+        auto win = d->context->window();
         if (!win) {
             return;
         }

--
Gitblit v1.9.1