@@ -458,12 +458,45 @@ void AppImageUpdateInformationPrivate::getInfo(void) {
458458
459459 // Check if it's a AppImageLauncher's path, if so then use the map file to
460460 // get the actual appimage path.
461+ bool tryUsingProgramArguments = false ;
461462 QRegExp rx (QString::fromUtf8 (" /run/user/*/appimagelauncherfs/*.AppImage" ));
462463 rx.setPatternSyntax (QRegExp::Wildcard);
463464
465+ if (rx.exactMatch (s_AppImagePath)) {
466+ QFileInfo pathInfo (s_AppImagePath);
467+ QString mapPath = pathInfo.absolutePath ();
468+ mapPath += QString::fromUtf8 (" /map" );
469+
470+ QString fileID = pathInfo.fileName ();
471+
472+ QFile mapFile (mapPath);
473+ if (mapFile.open (QIODevice::ReadOnly | QIODevice::Text)){
474+ while (!mapFile.atEnd ()) {
475+ QByteArray line = mapFile.readLine ();
476+ QString str (line);
477+ auto parts = str.split (QString::fromUtf8 (" -> " ));
478+ QString partID = parts.at (0 ).left (fileID.size ());
479+ if (fileID == partID){
480+ // Remove trailling new line
481+ QString parsedPath = parts.at (1 ).left (parts.at (1 ).size () - 1 );
482+
483+ bc.unlock ();
484+ setAppImage (parsedPath);
485+ bc.lock ();
486+ break ;
487+ }
488+ QCoreApplication::processEvents ();
489+ }
490+ mapFile.close ();
491+ }else {
492+ tryUsingProgramArguments = true ; // Try to parse from QCoreApplication.
493+ }
494+
495+ }
496+
464497 /*
465498 * Lets try getting it from QCoreApplication arguments. */
466- if (s_AppImagePath.isEmpty () || rx. exactMatch (s_AppImagePath) ) {
499+ if (s_AppImagePath.isEmpty () || tryUsingProgramArguments ) {
467500 auto arguments = QCoreApplication::arguments ();
468501 if (!arguments.isEmpty ()) {
469502 bc.unlock ();
@@ -595,8 +628,8 @@ void AppImageUpdateInformationPrivate::getInfo(void) {
595628 auto magicBytes = read (p_AppImage, /* offset=*/ 8 ,/* maxchars=*/ 3 );
596629 if (magicBytes[0 ] != ' A' || magicBytes[1 ] != ' I' ) {
597630 /*
598- * If its not an AppImage then lets check if its a linux desktop file , If so then parse the 'Exec'
599- * to find the actual AppImage.
631+ * If its not an AppImage then lets check if its a linux desktop file,
632+ * If so then parse the 'Exec' to find the actual AppImage.
600633 */
601634 magicBytes = read (p_AppImage, 0 , 15 );
602635 if (magicBytes == " [Desktop Entry]" ) {
0 commit comments