Skip to content

Commit

Permalink
Fix logging of warnings from before app is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 20, 2023
1 parent 2b5859c commit 2319f81
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ int main( int argc, char *argv[] )
{
//log messages written before creating QgsApplication
QStringList preApplicationLogMessages;
QStringList preApplicationWarningMessages;

#ifdef Q_OS_UNIX
// Increase file resource limits (i.e., number of allowed open files)
Expand Down Expand Up @@ -990,7 +991,7 @@ int main( int argc, char *argv[] )
{
if ( !QgsSettings::setGlobalSettingsPath( globalsettingsfile ) )
{
preApplicationLogMessages << QObject::tr( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" );
preApplicationWarningMessages << QObject::tr( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" );
}
else
{
Expand Down Expand Up @@ -1166,8 +1167,11 @@ int main( int argc, char *argv[] )
QgsApplication::init( profileFolder );

//write the log messages written before creating QgsApplication
for ( const QString &preApplicationLogMessage : std::as_const( preApplicationWarningMessages ) )
QgsMessageLog::logMessage( preApplicationLogMessage, QString(), Qgis::MessageLevel::Warning );

for ( const QString &preApplicationLogMessage : std::as_const( preApplicationLogMessages ) )
QgsMessageLog::logMessage( preApplicationLogMessage );
QgsMessageLog::logMessage( preApplicationLogMessage, QString(), Qgis::MessageLevel::Info );

// Settings migration is only supported on the default profile for now.
if ( profileName == QLatin1String( "default" ) )
Expand Down

0 comments on commit 2319f81

Please sign in to comment.