Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(geometry_checker): do not call crs() on layer from another thread #58291

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The geometry will not be reprojected regardless of useMapCrs.
%End



QString layerId() const;
%Docstring
The layer id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The geometry will not be reprojected regardless of useMapCrs.
%End



QString layerId() const;
%Docstring
The layer id.
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
{
const QMap<QgsFeatureId, QList<QgsGeometryCheck::Change>> &layerChanges = it.value();
QgsFeaturePool *featurePool = mFeaturePools[it.key()];
QgsCoordinateTransform t( featurePool->layer()->crs(), mContext->mapCrs, QgsProject::instance() );
QgsCoordinateTransform t( featurePool->crs(), mContext->mapCrs, QgsProject::instance() );
t.setBallparkTransformsAreAppropriate( true );
for ( auto layerChangeIt = layerChanges.constBegin(); layerChangeIt != layerChanges.constEnd(); ++layerChangeIt )
{
Expand Down Expand Up @@ -189,7 +189,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
for ( auto it = mFeaturePools.constBegin(); it != mFeaturePools.constEnd(); it++ )
{
QgsFeaturePool *featurePool = it.value();
QgsCoordinateTransform t( mContext->mapCrs, featurePool->layer()->crs(), QgsProject::instance() );
QgsCoordinateTransform t( mContext->mapCrs, featurePool->crs(), QgsProject::instance() );
recheckAreaFeatures[it.key()] = featurePool->getIntersects( t.transform( recheckArea ) );
}

Expand Down
20 changes: 8 additions & 12 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,15 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
}
if ( !layerFeature.useMapCrs() )
{
QgsVectorLayer *vl = layerFeature.layer().data();
if ( vl )
const QgsCoordinateTransform ct( layerFeature.layerCrs(), check->context()->mapCrs, check->context()->transformContext );
try
{
const QgsCoordinateTransform ct( vl->crs(), check->context()->mapCrs, check->context()->transformContext );
try
{
mGeometry.transform( ct );
mErrorLocation = ct.transform( mErrorLocation );
}
catch ( const QgsCsException & )
{
QgsDebugError( QStringLiteral( "Can not show error in current map coordinate reference system" ) );
}
mGeometry.transform( ct );
mErrorLocation = ct.transform( mErrorLocation );
}
catch ( const QgsCsException & )
{
QgsDebugError( QStringLiteral( "Can not show error in current map coordinate reference system" ) );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ QgsFeature QgsGeometryCheckerUtils::LayerFeature::feature() const
return mFeature;
}

QgsCoordinateReferenceSystem QgsGeometryCheckerUtils::LayerFeature::layerCrs() const
{
return mFeaturePool->crs();
}

QPointer<QgsVectorLayer> QgsGeometryCheckerUtils::LayerFeature::layer() const
{
return mFeaturePool->layerPtr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class ANALYSIS_EXPORT QgsGeometryCheckerUtils
*/
QgsFeature feature() const;

/**
* The layer CRS.
*/
QgsCoordinateReferenceSystem layerCrs() const SIP_SKIP;

/**
* The layer.
*/
Expand Down