diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 89b78fea7c27..67f8295b3fae 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -847,7 +847,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh endProfile(); // load GUI: actions, menus, toolbars - profiler->start( tr( "Application startup" ) ); startProfile( tr( "Setting up UI" ) ); setupUi( this ); // because mActionToggleMapOnly can hide the menu (thereby disabling menu actions), @@ -861,7 +860,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh ////////// - startProfile( tr( "Checking database" ) ); + startProfile( tr( "Checking user database" ) ); mSplash->showMessage( tr( "Checking database" ), Qt::AlignHCenter | Qt::AlignBottom ); qApp->processEvents(); // Do this early on before anyone else opens it and prevents us copying it @@ -1629,7 +1628,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh #ifdef ANDROID toggleFullScreen(); #endif - profiler->end(); mStartupProfilerWidgetFactory.reset( qgis::make_unique< QgsProfilerWidgetFactory >( profiler ) ); diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 1a13be63d4a2..44aebbac7ff3 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -346,10 +346,17 @@ void QgsApplication::init( QString profileFolder ) // so we read actual value in main.cpp ABISYM( sMaxThreads ) = -1; - colorSchemeRegistry()->addDefaultSchemes(); - colorSchemeRegistry()->initStyleScheme(); + { + QgsScopedRuntimeProfile profile( tr( "Load color schemes" ) ); + colorSchemeRegistry()->addDefaultSchemes(); + colorSchemeRegistry()->initStyleScheme(); + } + + { + QgsScopedRuntimeProfile profile( tr( "Load bookmarks" ) ); + bookmarkManager()->initialize( QgsApplication::qgisSettingsDirPath() + "/bookmarks.xml" ); + } - bookmarkManager()->initialize( QgsApplication::qgisSettingsDirPath() + "/bookmarks.xml" ); if ( !members()->mStyleModel ) members()->mStyleModel = new QgsStyleModel( QgsStyle::defaultStyle() ); @@ -2234,33 +2241,134 @@ QgsApplication::ApplicationMembers::ApplicationMembers() // will need to be careful with the order of creation/destruction mMessageLog = new QgsMessageLog(); mProfiler = new QgsRuntimeProfiler(); - mConnectionRegistry = new QgsConnectionRegistry(); - mTaskManager = new QgsTaskManager(); - mActionScopeRegistry = new QgsActionScopeRegistry(); - mNumericFormatRegistry = new QgsNumericFormatRegistry(); - mFieldFormatterRegistry = new QgsFieldFormatterRegistry(); - mSvgCache = new QgsSvgCache(); - mImageCache = new QgsImageCache(); - mColorSchemeRegistry = new QgsColorSchemeRegistry(); - mPaintEffectRegistry = new QgsPaintEffectRegistry(); - mSymbolLayerRegistry = new QgsSymbolLayerRegistry(); - mCalloutRegistry = new QgsCalloutRegistry(); - mRendererRegistry = new QgsRendererRegistry(); - mRasterRendererRegistry = new QgsRasterRendererRegistry(); - mGpsConnectionRegistry = new QgsGpsConnectionRegistry(); - mPluginLayerRegistry = new QgsPluginLayerRegistry(); - mProcessingRegistry = new QgsProcessingRegistry(); + + { + mProfiler->start( tr( "Create connection registry" ) ); + mConnectionRegistry = new QgsConnectionRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup task manager" ) ); + mTaskManager = new QgsTaskManager(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup action scope registry" ) ); + mActionScopeRegistry = new QgsActionScopeRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup numeric formats" ) ); + mNumericFormatRegistry = new QgsNumericFormatRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup field formats" ) ); + mFieldFormatterRegistry = new QgsFieldFormatterRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup SVG cache" ) ); + mSvgCache = new QgsSvgCache(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup image cache" ) ); + mImageCache = new QgsImageCache(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup color scheme registry" ) ); + mColorSchemeRegistry = new QgsColorSchemeRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup paint effect" ) ); + mPaintEffectRegistry = new QgsPaintEffectRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup symbol layer registry" ) ); + mSymbolLayerRegistry = new QgsSymbolLayerRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup callout registry" ) ); + mCalloutRegistry = new QgsCalloutRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup renderer registry" ) ); + mRendererRegistry = new QgsRendererRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup raster renderer registry" ) ); + mRasterRendererRegistry = new QgsRasterRendererRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup GPS registry" ) ); + mGpsConnectionRegistry = new QgsGpsConnectionRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup plugin layer registry" ) ); + mPluginLayerRegistry = new QgsPluginLayerRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup Processing registry" ) ); + mProcessingRegistry = new QgsProcessingRegistry(); + mProfiler->end(); + } mPageSizeRegistry = new QgsPageSizeRegistry(); - mLayoutItemRegistry = new QgsLayoutItemRegistry(); - mLayoutItemRegistry->populate(); - mAnnotationRegistry = new QgsAnnotationRegistry(); - m3DRendererRegistry = new Qgs3DRendererRegistry(); - mProjectStorageRegistry = new QgsProjectStorageRegistry(); - mNetworkContentFetcherRegistry = new QgsNetworkContentFetcherRegistry(); - mValidityCheckRegistry = new QgsValidityCheckRegistry(); - mClassificationMethodRegistry = new QgsClassificationMethodRegistry(); - mBookmarkManager = new QgsBookmarkManager( nullptr ); - mScaleBarRendererRegistry = new QgsScaleBarRendererRegistry(); + { + mProfiler->start( tr( "Setup layout item registry" ) ); + mLayoutItemRegistry = new QgsLayoutItemRegistry(); + mLayoutItemRegistry->populate(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup annotation registry" ) ); + mAnnotationRegistry = new QgsAnnotationRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup 3D renderer registry" ) ); + m3DRendererRegistry = new Qgs3DRendererRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup project storage registry" ) ); + mProjectStorageRegistry = new QgsProjectStorageRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup network content cache" ) ); + mNetworkContentFetcherRegistry = new QgsNetworkContentFetcherRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup layout check registry" ) ); + mValidityCheckRegistry = new QgsValidityCheckRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup classification registry" ) ); + mClassificationMethodRegistry = new QgsClassificationMethodRegistry(); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup bookmark manager" ) ); + mBookmarkManager = new QgsBookmarkManager( nullptr ); + mProfiler->end(); + } + { + mProfiler->start( tr( "Setup scalebar registry" ) ); + mScaleBarRendererRegistry = new QgsScaleBarRendererRegistry(); + mProfiler->end(); + } } QgsApplication::ApplicationMembers::~ApplicationMembers() diff --git a/src/core/symbology/qgsstyle.cpp b/src/core/symbology/qgsstyle.cpp index 2b483d2d1af9..cfadb60992b5 100644 --- a/src/core/symbology/qgsstyle.cpp +++ b/src/core/symbology/qgsstyle.cpp @@ -28,6 +28,7 @@ #include "qgsmarkersymbollayer.h" #include "qgslinesymbollayer.h" #include "qgsfillsymbollayer.h" +#include "qgsruntimeprofiler.h" #include #include @@ -111,6 +112,7 @@ QgsStyle *QgsStyle::defaultStyle() // static { if ( !sDefaultStyle ) { + QgsScopedRuntimeProfile profile( tr( "Load default style database" ) ); QString styleFilename = QgsApplication::userStylePath(); // copy default style if user style doesn't exist @@ -575,97 +577,112 @@ bool QgsStyle::load( const QString &filename ) ); runEmptyQuery( query ); - // First create all the main symbols - query = QgsSqlite3Mprintf( "SELECT * FROM symbol" ); - statement = mCurrentDB.prepare( query, rc ); - - while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QDomDocument doc; - QString symbol_name = statement.columnAsText( SymbolName ); - QString xmlstring = statement.columnAsText( SymbolXML ); - if ( !doc.setContent( xmlstring ) ) + QgsScopedRuntimeProfile profile( tr( "Load symbols" ) ); + // First create all the main symbols + query = QgsSqlite3Mprintf( "SELECT * FROM symbol" ); + statement = mCurrentDB.prepare( query, rc ); + + while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QgsDebugMsg( "Cannot open symbol " + symbol_name ); - continue; - } + QDomDocument doc; + QString symbol_name = statement.columnAsText( SymbolName ); + QString xmlstring = statement.columnAsText( SymbolXML ); + if ( !doc.setContent( xmlstring ) ) + { + QgsDebugMsg( "Cannot open symbol " + symbol_name ); + continue; + } - QDomElement symElement = doc.documentElement(); - QgsSymbol *symbol = QgsSymbolLayerUtils::loadSymbol( symElement, QgsReadWriteContext() ); - if ( symbol ) - mSymbols.insert( symbol_name, symbol ); + QDomElement symElement = doc.documentElement(); + QgsSymbol *symbol = QgsSymbolLayerUtils::loadSymbol( symElement, QgsReadWriteContext() ); + if ( symbol ) + mSymbols.insert( symbol_name, symbol ); + } } - query = QgsSqlite3Mprintf( "SELECT * FROM colorramp" ); - statement = mCurrentDB.prepare( query, rc ); - while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QDomDocument doc; - QString ramp_name = statement.columnAsText( ColorrampName ); - QString xmlstring = statement.columnAsText( ColorrampXML ); - if ( !doc.setContent( xmlstring ) ) + QgsScopedRuntimeProfile profile( tr( "Load color ramps" ) ); + query = QgsSqlite3Mprintf( "SELECT * FROM colorramp" ); + statement = mCurrentDB.prepare( query, rc ); + while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QgsDebugMsg( "Cannot open symbol " + ramp_name ); - continue; + QDomDocument doc; + QString ramp_name = statement.columnAsText( ColorrampName ); + QString xmlstring = statement.columnAsText( ColorrampXML ); + if ( !doc.setContent( xmlstring ) ) + { + QgsDebugMsg( "Cannot open symbol " + ramp_name ); + continue; + } + QDomElement rampElement = doc.documentElement(); + QgsColorRamp *ramp = QgsSymbolLayerUtils::loadColorRamp( rampElement ); + if ( ramp ) + mColorRamps.insert( ramp_name, ramp ); } - QDomElement rampElement = doc.documentElement(); - QgsColorRamp *ramp = QgsSymbolLayerUtils::loadColorRamp( rampElement ); - if ( ramp ) - mColorRamps.insert( ramp_name, ramp ); } - query = QgsSqlite3Mprintf( "SELECT * FROM textformat" ); - statement = mCurrentDB.prepare( query, rc ); - while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QDomDocument doc; - const QString formatName = statement.columnAsText( TextFormatName ); - const QString xmlstring = statement.columnAsText( TextFormatXML ); - if ( !doc.setContent( xmlstring ) ) + QgsScopedRuntimeProfile profile( tr( "Load text formats" ) ); + query = QgsSqlite3Mprintf( "SELECT * FROM textformat" ); + statement = mCurrentDB.prepare( query, rc ); + while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QgsDebugMsg( "Cannot open text format " + formatName ); - continue; + QDomDocument doc; + const QString formatName = statement.columnAsText( TextFormatName ); + const QString xmlstring = statement.columnAsText( TextFormatXML ); + if ( !doc.setContent( xmlstring ) ) + { + QgsDebugMsg( "Cannot open text format " + formatName ); + continue; + } + QDomElement formatElement = doc.documentElement(); + QgsTextFormat format; + format.readXml( formatElement, QgsReadWriteContext() ); + mTextFormats.insert( formatName, format ); } - QDomElement formatElement = doc.documentElement(); - QgsTextFormat format; - format.readXml( formatElement, QgsReadWriteContext() ); - mTextFormats.insert( formatName, format ); } - query = QgsSqlite3Mprintf( "SELECT * FROM labelsettings" ); - statement = mCurrentDB.prepare( query, rc ); - while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QDomDocument doc; - const QString settingsName = statement.columnAsText( LabelSettingsName ); - const QString xmlstring = statement.columnAsText( LabelSettingsXML ); - if ( !doc.setContent( xmlstring ) ) + QgsScopedRuntimeProfile profile( tr( "Load label settings" ) ); + query = QgsSqlite3Mprintf( "SELECT * FROM labelsettings" ); + statement = mCurrentDB.prepare( query, rc ); + while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QgsDebugMsg( "Cannot open label settings " + settingsName ); - continue; + QDomDocument doc; + const QString settingsName = statement.columnAsText( LabelSettingsName ); + const QString xmlstring = statement.columnAsText( LabelSettingsXML ); + if ( !doc.setContent( xmlstring ) ) + { + QgsDebugMsg( "Cannot open label settings " + settingsName ); + continue; + } + QDomElement settingsElement = doc.documentElement(); + QgsPalLayerSettings settings; + settings.readXml( settingsElement, QgsReadWriteContext() ); + mLabelSettings.insert( settingsName, settings ); } - QDomElement settingsElement = doc.documentElement(); - QgsPalLayerSettings settings; - settings.readXml( settingsElement, QgsReadWriteContext() ); - mLabelSettings.insert( settingsName, settings ); } - query = QgsSqlite3Mprintf( "SELECT * FROM legendpatchshapes" ); - statement = mCurrentDB.prepare( query, rc ); - while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QDomDocument doc; - const QString settingsName = statement.columnAsText( LegendPatchTableName ); - const QString xmlstring = statement.columnAsText( LegendPatchTableXML ); - if ( !doc.setContent( xmlstring ) ) + QgsScopedRuntimeProfile profile( tr( "Load legend patch shapes" ) ); + query = QgsSqlite3Mprintf( "SELECT * FROM legendpatchshapes" ); + statement = mCurrentDB.prepare( query, rc ); + while ( rc == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) { - QgsDebugMsg( "Cannot open legend patch shape " + settingsName ); - continue; + QDomDocument doc; + const QString settingsName = statement.columnAsText( LegendPatchTableName ); + const QString xmlstring = statement.columnAsText( LegendPatchTableXML ); + if ( !doc.setContent( xmlstring ) ) + { + QgsDebugMsg( "Cannot open legend patch shape " + settingsName ); + continue; + } + QDomElement settingsElement = doc.documentElement(); + QgsLegendPatchShape shape; + shape.readXml( settingsElement, QgsReadWriteContext() ); + mLegendPatchShapes.insert( settingsName, shape ); } - QDomElement settingsElement = doc.documentElement(); - QgsLegendPatchShape shape; - shape.readXml( settingsElement, QgsReadWriteContext() ); - mLegendPatchShapes.insert( settingsName, shape ); } mFileName = filename;