mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Avoid some other lengthy lambdas in call_once
This commit is contained in:
parent
7906258d01
commit
8159590ecf
@ -194,10 +194,7 @@ void QgsCallout::setEnabled( bool enabled )
|
|||||||
QgsPropertiesDefinition QgsCallout::propertyDefinitions()
|
QgsPropertiesDefinition QgsCallout::propertyDefinitions()
|
||||||
{
|
{
|
||||||
static std::once_flag initialized;
|
static std::once_flag initialized;
|
||||||
std::call_once( initialized, [ = ]( )
|
std::call_once( initialized, initPropertyDefinitions );
|
||||||
{
|
|
||||||
initPropertyDefinitions();
|
|
||||||
} );
|
|
||||||
return sPropertyDefinitions;
|
return sPropertyDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,11 +123,7 @@ void QgsNetworkDiskCache::clear()
|
|||||||
return sDiskCache.clear();
|
return sDiskCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 QgsNetworkDiskCache::smartCacheSize( const QString &cacheDir )
|
void determineSmartCacheSize( const QString &cacheDir, qint64 &cacheSize )
|
||||||
{
|
|
||||||
static qint64 cacheSize = 0;
|
|
||||||
static std::once_flag initialized;
|
|
||||||
std::call_once( initialized, [ = ]
|
|
||||||
{
|
{
|
||||||
std::function<qint64( const QString & )> dirSize;
|
std::function<qint64( const QString & )> dirSize;
|
||||||
dirSize = [&dirSize]( const QString & dirPath ) -> qint64
|
dirSize = [&dirSize]( const QString & dirPath ) -> qint64
|
||||||
@ -184,14 +180,19 @@ qint64 QgsNetworkDiskCache::smartCacheSize( const QString &cacheDir )
|
|||||||
|
|
||||||
// Add 16% of free space up to 500 MB
|
// Add 16% of free space up to 500 MB
|
||||||
cacheSize10MB += std::max( 2LL, static_cast<qint64>( available10MB * 0.16 ) );
|
cacheSize10MB += std::max( 2LL, static_cast<qint64>( available10MB * 0.16 ) );
|
||||||
#else
|
#else \
|
||||||
// Add 30% of free space up to 500 MB
|
// Add 30% of free space up to 500 MB
|
||||||
cacheSize10MB += std::max( 5LL, static_cast<qint64>( available10MB * 0.30 ) );
|
cacheSize10MB += std::max( 5LL, static_cast<qint64>( available10MB * 0.30 ) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
cacheSize = cacheSize10MB * 10 * 1024 * 1024;
|
cacheSize = cacheSize10MB * 10 * 1024 * 1024;
|
||||||
// NOLINTEND(bugprone-narrowing-conversions)
|
// NOLINTEND(bugprone-narrowing-conversions)
|
||||||
} );
|
}
|
||||||
|
|
||||||
return cacheSize;
|
qint64 QgsNetworkDiskCache::smartCacheSize( const QString &cacheDir )
|
||||||
|
{
|
||||||
|
static qint64 sCacheSize = 0;
|
||||||
|
static std::once_flag initialized;
|
||||||
|
std::call_once( initialized, determineSmartCacheSize, cacheDir, sCacheSize );
|
||||||
|
return sCacheSize;
|
||||||
}
|
}
|
||||||
|
@ -2961,7 +2961,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS
|
|||||||
|
|
||||||
QgsDebugMsgLevel( "Raster filter list built: " + fileFiltersString, 2 );
|
QgsDebugMsgLevel( "Raster filter list built: " + fileFiltersString, 2 );
|
||||||
QgsDebugMsgLevel( "Raster extension list built: " + extensions.join( ' ' ), 2 );
|
QgsDebugMsgLevel( "Raster extension list built: " + extensions.join( ' ' ), 2 );
|
||||||
} // buildSupportedRasterFileFilter_()
|
}
|
||||||
|
|
||||||
bool QgsGdalProvider::isValidRasterFileName( QString const &fileNameQString, QString &retErrMsg )
|
bool QgsGdalProvider::isValidRasterFileName( QString const &fileNameQString, QString &retErrMsg )
|
||||||
{
|
{
|
||||||
@ -4429,12 +4429,7 @@ QList<QgsProviderSublayerDetails> QgsGdalProviderMetadata::querySublayers( const
|
|||||||
|
|
||||||
// get supported extensions
|
// get supported extensions
|
||||||
static std::once_flag initialized;
|
static std::once_flag initialized;
|
||||||
std::call_once( initialized, [ = ]
|
std::call_once( initialized, buildSupportedRasterFileFilterAndExtensions, sFilterString, sExtensions, sWildcards );
|
||||||
{
|
|
||||||
buildSupportedRasterFileFilterAndExtensions( sFilterString, sExtensions, sWildcards );
|
|
||||||
QgsDebugMsgLevel( QStringLiteral( "extensions: " ) + sExtensions.join( ' ' ), 2 );
|
|
||||||
QgsDebugMsgLevel( QStringLiteral( "wildcards: " ) + sWildcards.join( ' ' ), 2 );
|
|
||||||
} );
|
|
||||||
|
|
||||||
const QString suffix = uriParts.value( QStringLiteral( "vsiSuffix" ) ).toString().isEmpty()
|
const QString suffix = uriParts.value( QStringLiteral( "vsiSuffix" ) ).toString().isEmpty()
|
||||||
? pathInfo.suffix().toLower()
|
? pathInfo.suffix().toLower()
|
||||||
|
@ -226,38 +226,7 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsApplication::init( QString profileFolder )
|
void registerMetaTypes()
|
||||||
{
|
|
||||||
// Initialize application members in desktop app (at this point, profile folder is known)
|
|
||||||
if ( platform() == QLatin1String( "desktop" ) )
|
|
||||||
{
|
|
||||||
instance()->mApplicationMembers = new ApplicationMembers();
|
|
||||||
instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( profileFolder.isEmpty() )
|
|
||||||
{
|
|
||||||
if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) )
|
|
||||||
{
|
|
||||||
profileFolder = getenv( "QGIS_CUSTOM_CONFIG_PATH" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
|
|
||||||
}
|
|
||||||
// This will normally get here for custom scripts that use QgsApplication.
|
|
||||||
// This doesn't get this hit for QGIS Desktop because we setup the profile via main
|
|
||||||
QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( profileFolder );
|
|
||||||
QgsUserProfileManager manager( rootProfileFolder );
|
|
||||||
QgsUserProfile *profile = manager.getProfile();
|
|
||||||
profileFolder = profile->folder();
|
|
||||||
delete profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
*sProfilePath() = profileFolder;
|
|
||||||
|
|
||||||
static std::once_flag sMetaTypesRegistered;
|
|
||||||
std::call_once( sMetaTypesRegistered, []
|
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
|
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
|
||||||
qRegisterMetaType<QgsDatabaseQueryLogEntry>( "QgsDatabaseQueryLogEntry" );
|
qRegisterMetaType<QgsDatabaseQueryLogEntry>( "QgsDatabaseQueryLogEntry" );
|
||||||
@ -322,7 +291,40 @@ void QgsApplication::init( QString profileFolder )
|
|||||||
qRegisterMetaType< QAuthenticator * >( "QAuthenticator*" );
|
qRegisterMetaType< QAuthenticator * >( "QAuthenticator*" );
|
||||||
qRegisterMetaType< QgsGpsInformation >( "QgsGpsInformation" );
|
qRegisterMetaType< QgsGpsInformation >( "QgsGpsInformation" );
|
||||||
qRegisterMetaType< QgsSensorThingsExpansionDefinition >( "QgsSensorThingsExpansionDefinition" );
|
qRegisterMetaType< QgsSensorThingsExpansionDefinition >( "QgsSensorThingsExpansionDefinition" );
|
||||||
} );
|
};
|
||||||
|
|
||||||
|
void QgsApplication::init( QString profileFolder )
|
||||||
|
{
|
||||||
|
// Initialize application members in desktop app (at this point, profile folder is known)
|
||||||
|
if ( platform() == QLatin1String( "desktop" ) )
|
||||||
|
{
|
||||||
|
instance()->mApplicationMembers = new ApplicationMembers();
|
||||||
|
instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profileFolder.isEmpty() )
|
||||||
|
{
|
||||||
|
if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) )
|
||||||
|
{
|
||||||
|
profileFolder = getenv( "QGIS_CUSTOM_CONFIG_PATH" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
|
||||||
|
}
|
||||||
|
// This will normally get here for custom scripts that use QgsApplication.
|
||||||
|
// This doesn't get this hit for QGIS Desktop because we setup the profile via main
|
||||||
|
QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( profileFolder );
|
||||||
|
QgsUserProfileManager manager( rootProfileFolder );
|
||||||
|
QgsUserProfile *profile = manager.getProfile();
|
||||||
|
profileFolder = profile->folder();
|
||||||
|
delete profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
*sProfilePath() = profileFolder;
|
||||||
|
|
||||||
|
static std::once_flag sMetaTypesRegistered;
|
||||||
|
std::call_once( sMetaTypesRegistered, registerMetaTypes );
|
||||||
|
|
||||||
( void ) resolvePkgPath();
|
( void ) resolvePkgPath();
|
||||||
|
|
||||||
|
@ -124,10 +124,7 @@ void QgsMapLayerElevationProperties::setDataDefinedProperties( const QgsProperty
|
|||||||
QgsPropertiesDefinition QgsMapLayerElevationProperties::propertyDefinitions()
|
QgsPropertiesDefinition QgsMapLayerElevationProperties::propertyDefinitions()
|
||||||
{
|
{
|
||||||
static std::once_flag initialized;
|
static std::once_flag initialized;
|
||||||
std::call_once( initialized, [ = ]( )
|
std::call_once( initialized, initPropertyDefinitions );
|
||||||
{
|
|
||||||
initPropertyDefinitions();
|
|
||||||
} );
|
|
||||||
return sPropertyDefinitions;
|
return sPropertyDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,9 +454,6 @@ void QgsRasterPipe::initPropertyDefinitions()
|
|||||||
QgsPropertiesDefinition QgsRasterPipe::propertyDefinitions()
|
QgsPropertiesDefinition QgsRasterPipe::propertyDefinitions()
|
||||||
{
|
{
|
||||||
static std::once_flag initialized;
|
static std::once_flag initialized;
|
||||||
std::call_once( initialized, [ = ]( )
|
std::call_once( initialized, initPropertyDefinitions );
|
||||||
{
|
|
||||||
initPropertyDefinitions();
|
|
||||||
} );
|
|
||||||
return sPropertyDefinitions;
|
return sPropertyDefinitions;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user