Skip to content

Commit

Permalink
Accomodate thread unsafety of QgsProject::createExpressionContextScope()
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 16, 2022
1 parent ac19285 commit 6872948
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/core/project/qgsproject.cpp
Expand Up @@ -501,7 +501,8 @@ void QgsProject::setTitle( const QString &title )

QString QgsProject::title() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mMetadata.title();
}
Expand Down Expand Up @@ -807,7 +808,8 @@ void QgsProject::setFileName( const QString &name )

QString QgsProject::fileName() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mFile.fileName();
}
Expand Down Expand Up @@ -835,7 +837,8 @@ QFileInfo QgsProject::fileInfo() const

QgsProjectStorage *QgsProject::projectStorage() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return QgsApplication::projectStorageRegistry()->projectStorageFromUri( mFile.fileName() );
}
Expand Down Expand Up @@ -871,7 +874,8 @@ QString QgsProject::absolutePath() const

QString QgsProject::absoluteFilePath() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( projectStorage() )
return QString();
Expand All @@ -884,7 +888,8 @@ QString QgsProject::absoluteFilePath() const

QString QgsProject::baseName() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( QgsProjectStorage *storage = projectStorage() )
{
Expand Down Expand Up @@ -923,7 +928,8 @@ void QgsProject::setFilePathStorage( Qgis::FilePathType type )

QgsCoordinateReferenceSystem QgsProject::crs() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mCrs;
}
Expand Down Expand Up @@ -953,7 +959,8 @@ void QgsProject::setCrs( const QgsCoordinateReferenceSystem &crs, bool adjustEll

QString QgsProject::ellipsoid() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( !crs().isValid() )
return geoNone();
Expand All @@ -975,7 +982,8 @@ void QgsProject::setEllipsoid( const QString &ellipsoid )

QgsCoordinateTransformContext QgsProject::transformContext() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mTransformContext;
}
Expand Down Expand Up @@ -2229,7 +2237,8 @@ bool QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup *group, Qgis::ProjectReadF

QVariantMap QgsProject::customVariables() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mCustomVariables;
}
Expand Down Expand Up @@ -3082,7 +3091,8 @@ QStringList QgsProject::readListEntry( const QString &scope,
const QStringList &def,
bool *ok ) const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

QgsProjectProperty *property = findKey_( scope, key, mProperties );

Expand Down Expand Up @@ -3608,7 +3618,8 @@ void QgsProject::setAreaUnits( QgsUnitTypes::AreaUnit unit )

QString QgsProject::homePath() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( !mCachedHomePath.isEmpty() )
return mCachedHomePath;
Expand Down Expand Up @@ -4461,7 +4472,8 @@ QString QgsProject::resolveAttachmentIdentifier( const QString &identifier ) con

const QgsProjectMetadata &QgsProject::metadata() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// this method is called quite extensively from other threads via QgsProject::createExpressionContextScope()
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mMetadata;
}
Expand Down

0 comments on commit 6872948

Please sign in to comment.