From c941a7fd0e11c46b78f276054c5f614de66b7c3d Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Tue, 8 Jul 2025 16:27:14 +0200 Subject: [PATCH] less broken wxserver --- launcher/gui/src/LauncherApp.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/launcher/gui/src/LauncherApp.cpp b/launcher/gui/src/LauncherApp.cpp index f01cdedc..017eff7b 100644 --- a/launcher/gui/src/LauncherApp.cpp +++ b/launcher/gui/src/LauncherApp.cpp @@ -2,21 +2,38 @@ // Created by Stepan Usatiuk on 11.07.2024. // -// For compilers that don't support precompilation, include "wx/wx.h" #include "wx/notebook.h" #include "LauncherApp.h" +#include + #include "LauncherAppMainFrame.h" #include "wx/taskbar.h" #include +#include + #include "wx/snglinst.h" IMPLEMENT_APP(LauncherApp) +static std::string getServerSocket() { +#ifdef __WIN32__ + return "dhfs-sock-" + wxGetUserId().ToStdString(); +#else + return wxStandardPaths::Get().GetUserLocalDataDir().ToStdString() + + "/" + "dhfs-sock-" + wxGetUserId().ToStdString(); +#endif +} + // This is executed upon startup, like 'main()' in non-wxWidgets programs. bool LauncherApp::OnInit() { m_checker = new wxSingleInstanceChecker; + if (!std::filesystem::is_directory(wxStandardPaths::Get().GetUserLocalDataDir().ToStdString()) + && !std::filesystem::create_directories(wxStandardPaths::Get().GetUserLocalDataDir().ToStdString())) { + wxLogError("Couldn't create data directory: %s", wxStandardPaths::Get().GetUserLocalDataDir()); + return false; + } if (m_checker->IsAnotherRunning()) { // wxLogError(_("Another program instance is already running, aborting.")); @@ -24,13 +41,16 @@ bool LauncherApp::OnInit() { m_checker = NULL; auto clinet = new wxClient(); - auto conn = clinet->MakeConnection("dhfs", "/Users/stepus53/dhfs-sock", "dhfs"); + auto conn = clinet->MakeConnection("dhfs", getServerSocket(), "dhfs"); conn->Execute("wakeup"); return false; } - m_server.Create("/Users/stepus53/dhfs-sock"); + if (!m_server.Create(getServerSocket())) { + wxLogError("Couldn't create server!"); + return false; + } wxFrame* frame = new LauncherAppMainFrame(NULL); frame->Show(true);