From c6f083b3e7747898460a69df9af0ded4e4375439 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 1 Nov 2024 15:48:01 +0100 Subject: [PATCH] Core: Add wrapper function Application::applicationPid() --- src/App/Application.cpp | 6 ++++++ src/App/Application.h | 1 + src/App/Document.cpp | 15 +++++++++------ src/Gui/Application.cpp | 2 +- src/Gui/DocumentRecovery.cpp | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 4eac6b9888..e4dab92157 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -47,6 +47,7 @@ #include #endif +#include #include #include #include @@ -1114,6 +1115,11 @@ Application::TransactionSignaller::~TransactionSignaller() { } } +int64_t Application::applicationPid() +{ + return QCoreApplication::applicationPid(); +} + std::string Application::getHomePath() { return mConfig["AppHomePath"]; diff --git a/src/App/Application.h b/src/App/Application.h index 4f3f1e8ffa..95ec7c2c16 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -399,6 +399,7 @@ public: static std::map &Config(){return mConfig;} static int GetARGC(){return _argc;} static char** GetARGV(){return _argv;} + static int64_t applicationPid(); //@} /** @name Application directories */ diff --git a/src/App/Document.cpp b/src/App/Document.cpp index c3e3f921d5..4f6c29466a 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -931,18 +931,21 @@ Document::~Document() std::string Document::getTransientDirectoryName(const std::string& uuid, const std::string& filename) const { // Create a directory name of the form: {ExeName}_Doc_{UUID}_{HASH}_{PID} - std::stringstream s; + std::stringstream out; QCryptographicHash hash(QCryptographicHash::Sha1); #if QT_VERSION < QT_VERSION_CHECK(6,3,0) hash.addData(filename.c_str(), filename.size()); #else hash.addData(QByteArrayView(filename.c_str(), filename.size())); #endif - s << App::Application::getUserCachePath() << App::Application::getExecutableName() - << "_Doc_" << uuid - << "_" << hash.result().toHex().left(6).constData() - << "_" << QCoreApplication::applicationPid(); - return s.str(); + out << App::Application::getUserCachePath() << App::Application::getExecutableName() + << "_Doc_" + << uuid + << "_" + << hash.result().toHex().left(6).constData() + << "_" + << App::Application::applicationPid(); + return out.str(); } //-------------------------------------------------------------------------- diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 574da62bd2..08b3eb2225 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -2176,7 +2176,7 @@ void tryRunEventLoop(GUISingleApplication& mainApp) out << App::Application::getUserCachePath() << App::Application::getExecutableName() << "_" - << QCoreApplication::applicationPid() + << App::Application::applicationPid() << ".lock"; // open a lock file with the PID diff --git a/src/Gui/DocumentRecovery.cpp b/src/Gui/DocumentRecovery.cpp index f4dd67c030..57db13c346 100644 --- a/src/Gui/DocumentRecovery.cpp +++ b/src/Gui/DocumentRecovery.cpp @@ -654,7 +654,7 @@ void DocumentRecoveryHandler::checkForPreviousCrashes(const std::function