Skip to content

Commit 304275a

Browse files
committed
fix QgsApplication::setPrefixPath
setPrefixPath was useless outside of the app since mPrefixPath was overwritten by env variables
1 parent 5b7b7be commit 304275a

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

src/core/qgsapplication.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,32 +208,35 @@ void QgsApplication::init( QString profileFolder )
208208
}
209209
else
210210
{
211-
char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
212-
if ( !prefixPath )
211+
if ( ABISYM( mPrefixPath ).isNull() )
213212
{
213+
char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
214+
if ( !prefixPath )
215+
{
214216
#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
215-
setPrefixPath( applicationDirPath(), true );
217+
setPrefixPath( applicationDirPath(), true );
216218
#elif defined(ANDROID)
217-
// this is "/data/data/org.qgis.qgis" in android
218-
QDir myDir( QDir::homePath() );
219-
myDir.cdUp();
220-
QString myPrefix = myDir.absolutePath();
221-
setPrefixPath( myPrefix, true );
219+
// this is "/data/data/org.qgis.qgis" in android
220+
QDir myDir( QDir::homePath() );
221+
myDir.cdUp();
222+
QString myPrefix = myDir.absolutePath();
223+
setPrefixPath( myPrefix, true );
222224
#else
223-
QDir myDir( applicationDirPath() );
224-
// Fix for server which is one level deeper in /usr/lib/cgi-bin
225-
if ( applicationDirPath().contains( QStringLiteral( "cgi-bin" ) ) )
225+
QDir myDir( applicationDirPath() );
226+
// Fix for server which is one level deeper in /usr/lib/cgi-bin
227+
if ( applicationDirPath().contains( QStringLiteral( "cgi-bin" ) ) )
228+
{
229+
myDir.cdUp();
230+
}
231+
myDir.cdUp(); // Go from /usr/bin or /usr/lib (for server) to /usr
232+
QString myPrefix = myDir.absolutePath();
233+
setPrefixPath( myPrefix, true );
234+
#endif
235+
}
236+
else
226237
{
227-
myDir.cdUp();
238+
setPrefixPath( prefixPath, true );
228239
}
229-
myDir.cdUp(); // Go from /usr/bin or /usr/lib (for server) to /usr
230-
QString myPrefix = myDir.absolutePath();
231-
setPrefixPath( myPrefix, true );
232-
#endif
233-
}
234-
else
235-
{
236-
setPrefixPath( prefixPath, true );
237240
}
238241
}
239242

0 commit comments

Comments
 (0)