mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:30:06 +00:00
use a random pid instead of 2 to avoid overlap in flatpaks
This commit is contained in:
parent
0ff0f6ea17
commit
28ca8df5df
1 changed files with 10 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#include <scwx/qt/manager/log_manager.hpp>
|
#include <scwx/qt/manager/log_manager.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
@ -57,6 +59,14 @@ void LogManager::InitializeLogFile()
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
||||||
.toStdString();
|
.toStdString();
|
||||||
p->pid_ = boost::this_process::get_id();
|
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_);
|
p->logFile_ = fmt::format("{}/supercell-wx.{}.log", p->logPath_, p->pid_);
|
||||||
|
|
||||||
// Create log directory if it doesn't exist
|
// Create log directory if it doesn't exist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue