@@ -91,9 +91,13 @@ QString ABISYM( QgsApplication::mLibraryPath );
91
91
QString ABISYM ( QgsApplication::mLibexecPath );
92
92
QString ABISYM ( QgsApplication::mThemeName );
93
93
QString ABISYM ( QgsApplication::mUIThemeName );
94
+ QString ABISYM ( QgsApplication::mProfilePath );
95
+
94
96
QStringList ABISYM ( QgsApplication::mDefaultSvgPaths );
95
97
QMap<QString, QString> ABISYM ( QgsApplication::mSystemEnvVars );
96
98
QString ABISYM ( QgsApplication::mConfigPath );
99
+
100
+ bool ABISYM ( QgsApplication::mInitialized ) = false;
97
101
bool ABISYM ( QgsApplication::mRunningFromBuildDir ) = false;
98
102
QString ABISYM ( QgsApplication::mBuildSourcePath );
99
103
#ifdef _MSC_VER
@@ -121,7 +125,7 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q
121
125
122
126
mApplicationMembers = new ApplicationMembers ();
123
127
124
- init ( profileFolder ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
128
+ ABISYM ( mProfilePath ) = profileFolder;
125
129
}
126
130
127
131
void QgsApplication::init ( QString profileFolder )
@@ -146,6 +150,8 @@ void QgsApplication::init( QString profileFolder )
146
150
delete profile;
147
151
}
148
152
153
+ ABISYM ( mProfilePath ) = profileFolder;
154
+
149
155
qRegisterMetaType<QgsGeometry::Error>( " QgsGeometry::Error" );
150
156
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( " QgsProcessingFeatureSourceDefinition" );
151
157
qRegisterMetaType<QgsProcessingOutputLayerDefinition>( " QgsProcessingOutputLayerDefinition" );
@@ -259,6 +265,8 @@ void QgsApplication::init( QString profileFolder )
259
265
// this should be read from QgsSettings but we don't know where they are at this point
260
266
// so we read actual value in main.cpp
261
267
ABISYM ( mMaxThreads ) = -1 ;
268
+
269
+ ABISYM ( mInitialized ) = true ;
262
270
}
263
271
264
272
QgsApplication::~QgsApplication ()
@@ -577,6 +585,35 @@ void QgsApplication::setThemeName( const QString &themeName )
577
585
ABISYM ( mThemeName ) = themeName;
578
586
}
579
587
588
+ QString QgsApplication::resolvePkgPath ()
589
+ {
590
+ #if defined(ANDROID)
591
+ QString prefixPath ( getenv ( " QGIS_PREFIX_PATH" ) ? getenv ( " QGIS_PREFIX_PATH" ) : QDir::homePath () );
592
+ #else
593
+ QString prefixPath ( getenv ( " QGIS_PREFIX_PATH" ) ? getenv ( " QGIS_PREFIX_PATH" ) : applicationDirPath () );
594
+ #endif
595
+ QFile f;
596
+ // "/../../.." is for Mac bundled app in build directory
597
+ Q_FOREACH ( const QString &path, QStringList () << " " << " /.." << " /bin" << " /../../.." )
598
+ {
599
+ f.setFileName ( prefixPath + path + " /qgisbuildpath.txt" );
600
+ QgsDebugMsg ( f.fileName () );
601
+ if ( f.exists () )
602
+ break ;
603
+ }
604
+
605
+ if ( f.exists () && f.open ( QIODevice::ReadOnly ) )
606
+ {
607
+ QgsDebugMsg ( " Running from build dir!" );
608
+ return f.readLine ().trimmed ();
609
+ }
610
+ else
611
+ {
612
+ return prefixPath + ' /' + QStringLiteral ( QGIS_DATA_SUBDIR );
613
+ }
614
+
615
+ }
616
+
580
617
QString QgsApplication::themeName ()
581
618
{
582
619
return ABISYM ( mThemeName );
@@ -951,6 +988,11 @@ QgsApplication::endian_t QgsApplication::endian()
951
988
952
989
void QgsApplication::initQgis ()
953
990
{
991
+ if ( !ABISYM ( mInitialized ) )
992
+ {
993
+ init ( ABISYM ( mProfilePath ) );
994
+ }
995
+
954
996
// set the provider plugin path (this creates provider registry)
955
997
QgsProviderRegistry::instance ( pluginPath () );
956
998
0 commit comments