Fixed "Single instance" locking issue on Linux with AppImage,
where the PrusaSlicer binary is mounted at a different mount point at each AppImage execution. Fixes Lock files in the local configuration directory are not deleted (#5733)
This commit is contained in:
parent
b7bfaea1ba
commit
7780221683
1 changed files with 13 additions and 7 deletions
|
@ -252,14 +252,20 @@ namespace instance_check_internal
|
||||||
|
|
||||||
bool instance_check(int argc, char** argv, bool app_config_single_instance)
|
bool instance_check(int argc, char** argv, bool app_config_single_instance)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
std::size_t hashed_path;
|
||||||
boost::system::error_code ec;
|
|
||||||
#endif
|
|
||||||
std::size_t hashed_path =
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::hash<std::string>{}(boost::filesystem::system_complete(argv[0]).string());
|
hashed_path = std::hash<std::string>{}(boost::filesystem::system_complete(argv[0]).string());
|
||||||
#else
|
#else
|
||||||
std::hash<std::string>{}(boost::filesystem::canonical(boost::filesystem::system_complete(argv[0]), ec).string());
|
boost::system::error_code ec;
|
||||||
|
#ifdef __linux
|
||||||
|
// If executed by an AppImage, start the AppImage, not the main process.
|
||||||
|
// see https://docs.appimage.org/packaging-guide/environment-variables.html#id2
|
||||||
|
const char *appimage_binary = std::getenv("APPIMAGE");
|
||||||
|
if (appimage_binary)
|
||||||
|
hashed_path = std::hash<std::string>{}(boost::filesystem::canonical(boost::filesystem::system_complete(appimage_binary, ec).string());
|
||||||
|
if (ec.value() > 0)
|
||||||
|
#endif // __linux
|
||||||
|
hashed_path = std::hash<std::string>{}(boost::filesystem::canonical(boost::filesystem::system_complete(argv[0]), ec).string());
|
||||||
if (ec.value() > 0) { // canonical was not able to find the executable (can happen with appimage on some systems. Does it fail on Fuse file systems?)
|
if (ec.value() > 0) { // canonical was not able to find the executable (can happen with appimage on some systems. Does it fail on Fuse file systems?)
|
||||||
ec.clear();
|
ec.clear();
|
||||||
// Compose path with boost canonical of folder and filename
|
// Compose path with boost canonical of folder and filename
|
||||||
|
@ -269,7 +275,7 @@ bool instance_check(int argc, char** argv, bool app_config_single_instance)
|
||||||
hashed_path = std::hash<std::string>{}(boost::filesystem::system_complete(argv[0]).string());
|
hashed_path = std::hash<std::string>{}(boost::filesystem::system_complete(argv[0]).string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // win32
|
#endif // _WIN32
|
||||||
|
|
||||||
std::string lock_name = std::to_string(hashed_path);
|
std::string lock_name = std::to_string(hashed_path);
|
||||||
GUI::wxGetApp().set_instance_hash(hashed_path);
|
GUI::wxGetApp().set_instance_hash(hashed_path);
|
||||||
|
|
Loading…
Reference in a new issue