diff options
author | Michael Klein <michael@fossekall.de> | 2021-09-20 14:41:02 +0200 |
---|---|---|
committer | Michael Klein <m.klein@mvz-labor-lb.de> | 2021-09-20 14:43:15 +0200 |
commit | f030b378f07ed01d003c6cbc47d4461cbf84a976 (patch) | |
tree | db5717e883439df11be1b675b5cd5d545fe7e629 | |
parent | Merge pull request #134 from itay-grudev/v3.3.0-changelog (diff) | |
download | singleapplication-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.cpp | 9 |
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 } |