From fcdea215be02234e51501088fdaf8f81b49fd1fd Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 12 Sep 2025 15:49:34 +0100 Subject: [PATCH] Reapply "refactor: App use Uniqueprt for SocketMultiplexer" This reverts commit 6f18cf74c5b796bc82ce44a4a85c67a3eea6b888. --- 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 2dc5ce64f..208d6e90d 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() @@ -119,7 +121,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 773a91e9c..4110886c5 100644 --- a/src/lib/deskflow/ClientApp.cpp +++ b/src/lib/deskflow/ClientApp.cpp @@ -372,8 +372,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 475d95acb..192d8ba90 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -574,8 +574,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