aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klein <michael@fossekall.de>2021-09-20 14:41:02 +0200
committerMichael Klein <m.klein@mvz-labor-lb.de>2021-09-20 14:43:15 +0200
commitf030b378f07ed01d003c6cbc47d4461cbf84a976 (patch)
treedb5717e883439df11be1b675b5cd5d545fe7e629
parentMerge pull request #134 from itay-grudev/v3.3.0-changelog (diff)
downloadsingleapplication-f030b378f07ed01d003c6cbc47d4461cbf84a976.tar.xz
Use AppImage path for hash when running as AppImage.
When an application is launched as AppImage, each instance is launched from its own FUSE-mounted filesystem, so each instance has its own executable path. The AppImage runtime sets the environment variable APPIMAGE to the absolute path to the .AppImage file, so we can use the content of this variable instead of QApplication::applicationFilePath() when set. Closes #77, #137
-rw-r--r--singleapplication_p.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/singleapplication_p.cpp b/singleapplication_p.cpp
index 1339728..6b4aa51 100644
--- a/singleapplication_p.cpp
+++ b/singleapplication_p.cpp
@@ -147,7 +147,14 @@ void SingleApplicationPrivate::genBlockServerName()
#ifdef Q_OS_WIN
appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() );
#else
- appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() );
+ QString appImagePath = qEnvironmentVariable( "APPIMAGE" );
+ if ( appImagePath.isEmpty() ) {
+ // Not running as AppImage: use path to executable file
+ appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() );
+ } else {
+ // Running as AppImage: Use absolute path to AppImage file
+ appData.addData( appImagePath.toUtf8() );
+ }
#endif
}