Skip to content

Commit 3b6d37f

Browse files
committedFeb 12, 2018
Lets try fix this
1 parent 2cbcf74 commit 3b6d37f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed
 

‎src/app/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ int main( int argc, char *argv[] )
798798
QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true );
799799
#endif
800800

801+
QApplication *subapp = new QApplication(argc, argv);
801802
// SetUp the QgsSettings Global Settings:
802803
// - use the path specified with --globalsettingsfile path,
803804
// - use the environment if not found
@@ -809,7 +810,8 @@ int main( int argc, char *argv[] )
809810

810811
if ( globalsettingsfile.isEmpty() )
811812
{
812-
QString default_globalsettingsfile = QgsApplication::pkgDataPath() + "/qgis_global_settings.ini";
813+
QString default_globalsettingsfile = QgsApplication::resolvePkgPath() + "/resources/qgis_global_settings.ini";
814+
QgsDebugMsg( "GLOABL SETTINGS FILE:" + default_globalsettingsfile );
813815
if ( QFile::exists( default_globalsettingsfile ) )
814816
{
815817
globalsettingsfile = default_globalsettingsfile;
@@ -849,6 +851,9 @@ int main( int argc, char *argv[] )
849851
}
850852
}
851853
delete globalSettings;
854+
delete subapp;
855+
856+
QgsDebugMsg( "CONFIG LOCAL STORAGE:" + configLocalStorageLocation );
852857

853858
QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( configLocalStorageLocation );
854859
QgsUserProfileManager manager( rootProfileFolder );

‎src/core/qgsapplication.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,36 @@ void QgsApplication::setThemeName( const QString &themeName )
577577
ABISYM( mThemeName ) = themeName;
578578
}
579579

580+
QString QgsApplication::resolvePkgPath()
581+
{
582+
#if defined(ANDROID)
583+
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : QDir::homePath() );
584+
#else
585+
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
586+
#endif
587+
QFile f;
588+
// "/../../.." is for Mac bundled app in build directory
589+
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
590+
{
591+
f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
592+
QgsDebugMsg(f.fileName());
593+
if ( f.exists() )
594+
break;
595+
}
596+
597+
if ( f.exists() && f.open( QIODevice::ReadOnly ) )
598+
{
599+
return f.readLine().trimmed();
600+
QgsDebugMsg("Running from build dir!");
601+
return buildSourcePath;
602+
}
603+
else
604+
{
605+
return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
606+
}
607+
608+
}
609+
580610
QString QgsApplication::themeName()
581611
{
582612
return ABISYM( mThemeName );

‎src/core/qgsapplication.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ class CORE_EXPORT QgsApplication : public QApplication
184184
*/
185185
static void setThemeName( const QString &themeName );
186186

187+
static QString resolvePkgPath( );
188+
187189
/**
188190
* Set the active theme to the specified theme.
189191
* The theme name should be a single word e.g. 'default','classic'.

0 commit comments

Comments
 (0)
Please sign in to comment.