Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Delay application member creation in desktop mode
  • Loading branch information
YoannQDQ authored and nyalldawson committed Apr 24, 2023
1 parent 78b76d9 commit cb2b12c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/main.cpp
Expand Up @@ -1155,6 +1155,8 @@ int main( int argc, char *argv[] )
// Set locale to emit QgsApplication's localeChanged signal
QgsApplication::setLocale( QLocale() );

QgsApplication::init( profileFolder );

//write the log messages written before creating QgsApplication
for ( const QString &preApplicationLogMessage : std::as_const( preApplicationLogMessages ) )
QgsMessageLog::logMessage( preApplicationLogMessage );
Expand Down Expand Up @@ -1202,8 +1204,6 @@ int main( int argc, char *argv[] )
QgsDebugMsgLevel( QStringLiteral( "\t - %1" ).arg( profileFolder ), 2 );
QgsDebugMsgLevel( QStringLiteral( "\t - %1" ).arg( rootProfileFolder ), 2 );

QgsApplication::init( profileFolder );

// Redefine QgsApplication::libraryPaths as necessary.
// IMPORTANT: Do *after* QgsApplication myApp(...), but *before* Qt uses any plugins,
// e.g. loading splash screen, setting window icon, etc.
Expand Down
23 changes: 18 additions & 5 deletions src/core/qgsapplication.cpp
Expand Up @@ -202,17 +202,30 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q
{
*sPlatformName() = platformName;

mApplicationMembers = new ApplicationMembers();

*sProfilePath() = profileFolder;

connect( instance(), &QgsApplication::localeChanged, &QgsDateTimeFieldFormatter::applyLocaleChange );

mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
// Delay application members initialization in desktop app (In desktop app, profile folder is not known at this point)
if ( platformName != QStringLiteral( "desktop" ) )
{
mApplicationMembers = new ApplicationMembers();
mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
}
else
{
*sProfilePath() = profileFolder;
}

}

void QgsApplication::init( QString profileFolder )
{
// Initialize application members in desktop app (at this point, profile folder is known)
if ( platform() == QStringLiteral( "desktop" ) )
{
instance()->mApplicationMembers = new ApplicationMembers();
instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
}

if ( profileFolder.isEmpty() )
{
if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) )
Expand Down

0 comments on commit cb2b12c

Please sign in to comment.