From 4d738b4784970e8de082489f6bc8b51029968d6b Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 18 Jun 2025 18:39:38 -0400 Subject: [PATCH] refactor: App use Uniqueprt for SocketMultiplexer basedon: https://github.com/input-leap/input-leap/commit/8dd6bc2c55f91c0d3048822bb25f6b668e22da3d --- src/lib/deskflow/App.h | 10 ++++++---- src/lib/deskflow/ClientApp.cpp | 3 +-- src/lib/deskflow/ServerApp.cpp | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/deskflow/App.h b/src/lib/deskflow/App.h index e0d163d63..1d9cacba5 100644 --- a/src/lib/deskflow/App.h +++ b/src/lib/deskflow/App.h @@ -11,6 +11,7 @@ #include "base/Log.h" #include "common/Common.h" #include "deskflow/IApp.h" +#include "net/SocketMultiplexer.h" #if SYSAPI_WIN32 #include "deskflow/win32/AppUtilWindows.h" @@ -18,6 +19,7 @@ #include "deskflow/unix/AppUtilUnix.h" #endif +#include #include namespace deskflow { @@ -91,14 +93,14 @@ public: { m_events = &events; } - void setSocketMultiplexer(SocketMultiplexer *sm) + void setSocketMultiplexer(std::unique_ptr &&sm) { - m_socketMultiplexer = sm; + m_socketMultiplexer = std::move(sm); } SocketMultiplexer *getSocketMultiplexer() const { - return m_socketMultiplexer; + return m_socketMultiplexer.get(); } static App &instance() @@ -120,7 +122,7 @@ private: static App *s_instance; FileLogOutputter *m_fileLog = nullptr; ARCH_APP_UTIL m_appUtil; - SocketMultiplexer *m_socketMultiplexer = nullptr; + std::unique_ptr m_socketMultiplexer; }; #if WINAPI_MSWINDOWS diff --git a/src/lib/deskflow/ClientApp.cpp b/src/lib/deskflow/ClientApp.cpp index 36733e7b4..6488858d6 100644 --- a/src/lib/deskflow/ClientApp.cpp +++ b/src/lib/deskflow/ClientApp.cpp @@ -389,8 +389,7 @@ int ClientApp::mainLoop() { // create socket multiplexer. this must happen after daemonization // on unix because threads evaporate across a fork(). - SocketMultiplexer multiplexer; - setSocketMultiplexer(&multiplexer); + setSocketMultiplexer(std::make_unique()); // start client, etc appUtil().startNode(); diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 8ff308f89..6761c2030 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -584,8 +584,7 @@ int ServerApp::mainLoop() { // create socket multiplexer. this must happen after daemonization // on unix because threads evaporate across a fork(). - SocketMultiplexer multiplexer; - setSocketMultiplexer(&multiplexer); + setSocketMultiplexer(std::make_unique()); // if configuration has no screens then add this system // as the default