Skip to content

Commit d3d5d7e

Browse files
committed
do not write logs before QgsApplication instace
because otherwise it creates a QgsProject without a QgsApplication and translation won't work anymore because it cannot connect the signal to the slot this fixes #20561 (partly copied from 8e7d37e)
1 parent 7f5afe6 commit d3d5d7e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/app/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ APP_EXPORT
432432
#endif
433433
int main( int argc, char *argv[] )
434434
{
435+
//log messages written before creating QgsApplicatoin
436+
QStringList preApplicationLogMessages;
437+
435438
#ifdef Q_OS_MACX
436439
// Increase file resource limits (i.e., number of allowed open files)
437440
// (from code provided by Larry Biehl, Purdue University, USA, from 'MultiSpec' project)
@@ -868,11 +871,11 @@ int main( int argc, char *argv[] )
868871
{
869872
if ( !QgsSettings::setGlobalSettingsPath( globalsettingsfile ) )
870873
{
871-
QgsMessageLog::logMessage( QObject::tr( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) );
874+
preApplicationLogMessages << QObject::tr( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" );
872875
}
873876
else
874877
{
875-
QgsMessageLog::logMessage( QObject::tr( "Successfully loaded globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) );
878+
preApplicationLogMessages << QObject::tr( "Successfully loaded globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" );
876879
}
877880
}
878881

@@ -972,6 +975,10 @@ int main( int argc, char *argv[] )
972975

973976
QgsApplication myApp( argc, argv, myUseGuiFlag );
974977

978+
//write the log messages written before creating QgsApplicatoin
979+
for ( QString const &preApplicationLogMessage : preApplicationLogMessages )
980+
QgsMessageLog::logMessage( preApplicationLogMessage );
981+
975982
// Settings migration is only supported on the default profile for now.
976983
if ( profileName == QLatin1String( "default" ) )
977984
{

0 commit comments

Comments
 (0)