Skip to content

Commit 2adebf2

Browse files
committed
better AppImage support
1 parent a282b92 commit 2adebf2

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/main.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,28 @@ int main(int argc, char **argv)
117117
QString browserDirectory = executableDirectory.absolutePath().toLatin1();
118118

119119
#ifdef Q_OS_LINUX
120+
QString appImageDirectory;
120121
QByteArray appImageEnvVariable = qgetenv("APPIMAGE");
121122

122123
if (appImageEnvVariable.length() > 0) {
123-
QFileInfo appImageFileInfo =
124-
QFileInfo(QString::fromLatin1(appImageEnvVariable));
125-
QString appImageDirectory = appImageFileInfo.path();
126-
127-
browserDirectory = appImageDirectory;
124+
appImageDirectory =
125+
QFileInfo(QString::fromLatin1(appImageEnvVariable)).path();
128126
}
129127
#endif
130128

131129
// ==============================
132130
// Perl directory:
133131
// ==============================
134-
135132
QString perlDirectory = browserDirectory + "/perl";
136133

134+
#ifdef Q_OS_LINUX
135+
// Embedded in an AppImage 'perl' directory
136+
// takes precedence over external 'perl' directory:
137+
if (QDir(appImageDirectory + "/perl").exists()) {
138+
perlDirectory = appImageDirectory + "/perl";
139+
}
140+
#endif
141+
137142
// ==============================
138143
// Perl interpreter:
139144
// ==============================
@@ -172,9 +177,16 @@ int main(int argc, char **argv)
172177
// ==============================
173178
// Resources directory:
174179
// ==============================
175-
176180
QString resourcesDirectory = browserDirectory + "/resources";
177181

182+
#ifdef Q_OS_LINUX
183+
// Embedded in an AppImage 'resources' directory
184+
// takes precedence over external 'resources' directory:
185+
if (QDir(appImageDirectory + "/resources").exists()) {
186+
resourcesDirectory = appImageDirectory + "/resources";
187+
}
188+
#endif
189+
178190
// ==============================
179191
// Application directory:
180192
// ==============================

0 commit comments

Comments
 (0)