Skip to content
Permalink
Browse files
Don't call init in QgsApplication
  • Loading branch information
NathanW2 committed Feb 12, 2018
1 parent 9198971 commit 3207600
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
@@ -798,7 +798,8 @@ int main( int argc, char *argv[] )
QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true );
#endif

QApplication *subapp = new QApplication(argc, argv);
QgsApplication myApp( argc, argv, myUseGuiFlag );

// SetUp the QgsSettings Global Settings:
// - use the path specified with --globalsettingsfile path,
// - use the environment if not found
@@ -851,7 +852,6 @@ int main( int argc, char *argv[] )
}
}
delete globalSettings;
delete subapp;

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

@@ -872,7 +872,7 @@ int main( int argc, char *argv[] )
QgsDebugMsg( QString( "\t - %1" ).arg( profileFolder ) );
QgsDebugMsg( QString( "\t - %1" ).arg( rootProfileFolder ) );

QgsApplication myApp( argc, argv, myUseGuiFlag, profileFolder );
myApp.init( profileFolder );

// Settings migration is only supported on the default profile for now.
if ( profileName == "default" )
@@ -91,9 +91,13 @@ QString ABISYM( QgsApplication::mLibraryPath );
QString ABISYM( QgsApplication::mLibexecPath );
QString ABISYM( QgsApplication::mThemeName );
QString ABISYM( QgsApplication::mUIThemeName );
QString ABISYM( QgsApplication::mProfilePath );

QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
QMap<QString, QString> ABISYM( QgsApplication::mSystemEnvVars );
QString ABISYM( QgsApplication::mConfigPath );

bool ABISYM( QgsApplication::mInitialized ) = false;
bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
QString ABISYM( QgsApplication::mBuildSourcePath );
#ifdef _MSC_VER
@@ -121,7 +125,7 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q

mApplicationMembers = new ApplicationMembers();

init( profileFolder ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
ABISYM( mProfilePath ) = profileFolder;
}

void QgsApplication::init( QString profileFolder )
@@ -146,6 +150,8 @@ void QgsApplication::init( QString profileFolder )
delete profile;
}

ABISYM( mProfilePath ) = profileFolder;

qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );
@@ -259,6 +265,8 @@ void QgsApplication::init( QString profileFolder )
// this should be read from QgsSettings but we don't know where they are at this point
// so we read actual value in main.cpp
ABISYM( mMaxThreads ) = -1;

ABISYM( mInitialized ) = true;
}

QgsApplication::~QgsApplication()
@@ -589,14 +597,14 @@ QString QgsApplication::resolvePkgPath()
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
{
f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
QgsDebugMsg(f.fileName());
QgsDebugMsg( f.fileName() );
if ( f.exists() )
break;
}

if ( f.exists() && f.open( QIODevice::ReadOnly ) )
{
QgsDebugMsg("Running from build dir!");
QgsDebugMsg( "Running from build dir!" );
return f.readLine().trimmed();
}
else
@@ -980,6 +988,11 @@ QgsApplication::endian_t QgsApplication::endian()

void QgsApplication::initQgis()
{
if ( !ABISYM( mInitialized ) )
{
init( ABISYM( mProfilePath ) );
}

// set the provider plugin path (this creates provider registry)
QgsProviderRegistry::instance( pluginPath() );

@@ -734,6 +734,7 @@ class CORE_EXPORT QgsApplication : public QApplication
static QObject *ABISYM( mFileOpenEventReceiver );
static QStringList ABISYM( mFileOpenEventList );

static QString ABISYM( mProfilePath );
static QString ABISYM( mUIThemeName );
static QString ABISYM( mPrefixPath );
static QString ABISYM( mPluginPath );
@@ -746,6 +747,8 @@ class CORE_EXPORT QgsApplication : public QApplication

static QString ABISYM( mConfigPath );

static bool ABISYM( mInitialized );

//! True when running from build directory, i.e. without 'make install'
static bool ABISYM( mRunningFromBuildDir );
//! Path to the source directory. valid only when running from build directory.

0 comments on commit 3207600

Please sign in to comment.