From 16dd7c74f121a7ffd5a4e7bdf629dc59c13f9ad1 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 17 Nov 2020 14:44:18 +0100 Subject: [PATCH] boost canonical fix at instance check. Hopefully a fix of #4973 --- src/slic3r/GUI/InstanceCheck.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/InstanceCheck.cpp b/src/slic3r/GUI/InstanceCheck.cpp index 4aaecd2b2..8067fc7f3 100644 --- a/src/slic3r/GUI/InstanceCheck.cpp +++ b/src/slic3r/GUI/InstanceCheck.cpp @@ -251,11 +251,24 @@ namespace instance_check_internal bool instance_check(int argc, char** argv, bool app_config_single_instance) { +#ifndef _WIN32 + boost::system::error_code ec; +#endif std::size_t hashed_path = #ifdef _WIN32 std::hash{}(boost::filesystem::system_complete(argv[0]).string()); #else - std::hash{}(boost::filesystem::canonical(boost::filesystem::system_complete(argv[0])).string()); + std::hash{}(boost::filesystem::canonical(boost::filesystem::system_complete(argv[0]), ec).string()); + if(ec.value() > 0) { // canonical was not able to find execitable (can happen with appimage on some systems) + ec.clear(); + // Compose path with boost canonical of folder and filename + hashed_path = std::hash{}(boost::filesystem::canonical(boost::filesystem::system_complete(argv[0]).parent_path(), ec).string() + "/" + boost::filesystem::system_complete(argv[0]).filename().string()); + if(ec.value() > 0) { + // Still not valid, process without canonical + hashed_path = std::hash{}(boost::filesystem::system_complete(argv[0]).string()); + + } + } #endif // win32 std::string lock_name = std::to_string(hashed_path);