From a8843bb04aeb314a088fa9ea4b577d14c1184ad1 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 3 Dec 2024 10:17:09 +0100 Subject: fix: variable 'mods_path' is reassigned a value before the old one has been used. --- src/core/function/GlobalSettingStation.cpp | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/core/function/GlobalSettingStation.cpp') diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp index 26b5d8b8..4c88fde4 100644 --- a/src/core/function/GlobalSettingStation.cpp +++ b/src/core/function/GlobalSettingStation.cpp @@ -136,6 +136,41 @@ class GlobalSettingStation::Impl { return app_modules_path(); } + [[nodiscard]] auto GetIntegratedModulePath() const -> QString { + const auto exec_binary_path = GetAppDir(); + +#if defined(__linux__) + // AppImage + if (!qEnvironmentVariable("APPIMAGE").isEmpty()) { + return qEnvironmentVariable("APPDIR") + "/usr/modules"; + } + // Flatpak + if (!qEnvironmentVariable("container").isEmpty()) { + return "/app/modules"; + } +#endif + +#if defined(_WIN32) || defined(WIN32) + +#ifdef NDEBUG + return exec_binary_path + "/../modules"; +#else + return exec_binary_path + "/../modules/bin"; +#endif + +#endif + +#if defined(__APPLE__) && defined(__MACH__) + +#ifdef NDEBUG + return exec_binary_path + "/../Modules"; +#endif + +#endif + + return exec_binary_path + "/modules"; + } + private: [[nodiscard]] auto app_config_file_path() const -> QString { return app_config_path_ + "/config.ini"; @@ -205,4 +240,8 @@ void GlobalSettingStation::ClearAllDataObjects() const { auto GlobalSettingStation::GetConfigPath() const -> QString { return p_->GetConfigPath(); } + +auto GlobalSettingStation::GetIntegratedModulePath() const -> QString { + return p_->GetIntegratedModulePath(); +} } // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3