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
This commit is contained in:
Michael Klein 2021-09-20 14:41:02 +02:00 committed by Michael Klein
parent d5b3852bd0
commit f030b378f0

View File

@ -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
}