From 28ca8df5df4ad9e6f5e0ce5108458afa2bbc24c7 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 7 Jun 2025 12:48:33 -0400 Subject: [PATCH] use a random pid instead of 2 to avoid overlap in flatpaks --- scwx-qt/source/scwx/qt/manager/log_manager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scwx-qt/source/scwx/qt/manager/log_manager.cpp b/scwx-qt/source/scwx/qt/manager/log_manager.cpp index 7ab18e56..34facaa4 100644 --- a/scwx-qt/source/scwx/qt/manager/log_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/log_manager.cpp @@ -1,6 +1,8 @@ #include #include +#include +#include #include #include #include @@ -57,6 +59,14 @@ void LogManager::InitializeLogFile() QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) .toStdString(); p->pid_ = boost::this_process::get_id(); + if (p->pid_ == 2) + { + // The pid == 2 means that this is likely a flatpak. We assign a random + // number in this case to avoid overlap, scince it is always 2 in a + // flatpak + std::srand(std::time({})); + p->pid_ = std::rand(); + } p->logFile_ = fmt::format("{}/supercell-wx.{}.log", p->logPath_, p->pid_); // Create log directory if it doesn't exist