Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Lets try fix this
  • Loading branch information
NathanW2 committed Feb 12, 2018
1 parent 2cbcf74 commit 3b6d37f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/main.cpp
Expand Up @@ -798,6 +798,7 @@ int main( int argc, char *argv[] )
QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true );
#endif

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

if ( globalsettingsfile.isEmpty() )
{
QString default_globalsettingsfile = QgsApplication::pkgDataPath() + "/qgis_global_settings.ini";
QString default_globalsettingsfile = QgsApplication::resolvePkgPath() + "/resources/qgis_global_settings.ini";
QgsDebugMsg( "GLOABL SETTINGS FILE:" + default_globalsettingsfile );
if ( QFile::exists( default_globalsettingsfile ) )
{
globalsettingsfile = default_globalsettingsfile;
Expand Down Expand Up @@ -849,6 +851,9 @@ int main( int argc, char *argv[] )
}
}
delete globalSettings;
delete subapp;

QgsDebugMsg( "CONFIG LOCAL STORAGE:" + configLocalStorageLocation );

QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( configLocalStorageLocation );
QgsUserProfileManager manager( rootProfileFolder );
Expand Down
30 changes: 30 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -577,6 +577,36 @@ void QgsApplication::setThemeName( const QString &themeName )
ABISYM( mThemeName ) = themeName;
}

QString QgsApplication::resolvePkgPath()
{
#if defined(ANDROID)
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : QDir::homePath() );
#else
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
#endif
QFile f;
// "/../../.." is for Mac bundled app in build directory
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
{
f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
QgsDebugMsg(f.fileName());
if ( f.exists() )
break;
}

if ( f.exists() && f.open( QIODevice::ReadOnly ) )
{
return f.readLine().trimmed();
QgsDebugMsg("Running from build dir!");
return buildSourcePath;
}
else
{
return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
}

}

QString QgsApplication::themeName()
{
return ABISYM( mThemeName );
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -184,6 +184,8 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static void setThemeName( const QString &themeName );

static QString resolvePkgPath( );

/**
* Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
Expand Down

0 comments on commit 3b6d37f

Please sign in to comment.