Skip to content
Permalink
Browse files

No unique connections on lambdas

  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 36e83f3 commit dfe788e9cefe4e0e42654b72f0980d924ef50b03
Showing with 32 additions and 29 deletions.
  1. +32 −29 src/app/qgsgeometryvalidationservice.cpp
@@ -83,7 +83,7 @@ void QgsGeometryValidationService::onLayersAdded( const QList<QgsMapLayer *> &la
connect( vectorLayer->geometryOptions(), &QgsGeometryOptions::checkConfigurationChanged, this, [this, vectorLayer]()
{
enableLayerChecks( vectorLayer );
}, Qt::UniqueConnection );
} );

connect( vectorLayer, &QgsVectorLayer::destroyed, this, [vectorLayer, this]()
{
@@ -253,35 +253,38 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )

checkInformation.topologyChecks = topologyChecks;

// Connect to all modifications on a layer that can introduce a geometry or topology error
// Also connect to the beforeCommitChanges signal, so we can trigger topology checks
// We keep all connections around in a list, so if in the future all checks get disabled
// we can kill those connections to be sure the layer does not even get a tiny bit of overhead.
checkInformation.connections
<< connect( layer, &QgsVectorLayer::featureAdded, this, [this, layer]( QgsFeatureId fid )
{
onFeatureAdded( layer, fid );
}, Qt::UniqueConnection );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::geometryChanged, this, [this, layer]( QgsFeatureId fid, const QgsGeometry & geometry )
{
onGeometryChanged( layer, fid, geometry );
}, Qt::UniqueConnection );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::featureDeleted, this, [this, layer]( QgsFeatureId fid )
if ( checkInformation.connections.empty() )
{
onFeatureDeleted( layer, fid );
}, Qt::UniqueConnection );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::beforeCommitChanges, this, [this, layer]()
{
onBeforeCommitChanges( layer );
}, Qt::UniqueConnection );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::editingStopped, this, [this, layer]()
{
onEditingStopped( layer );
}, Qt::UniqueConnection );
// Connect to all modifications on a layer that can introduce a geometry or topology error
// Also connect to the beforeCommitChanges signal, so we can trigger topology checks
// We keep all connections around in a list, so if in the future all checks get disabled
// we can kill those connections to be sure the layer does not even get a tiny bit of overhead.
checkInformation.connections
<< connect( layer, &QgsVectorLayer::featureAdded, this, [this, layer]( QgsFeatureId fid )
{
onFeatureAdded( layer, fid );
} );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::geometryChanged, this, [this, layer]( QgsFeatureId fid, const QgsGeometry & geometry )
{
onGeometryChanged( layer, fid, geometry );
} );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::featureDeleted, this, [this, layer]( QgsFeatureId fid )
{
onFeatureDeleted( layer, fid );
} );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::beforeCommitChanges, this, [this, layer]()
{
onBeforeCommitChanges( layer );
} );
checkInformation.connections
<< connect( layer, &QgsVectorLayer::editingStopped, this, [this, layer]()
{
onEditingStopped( layer );
} );
}
}

void QgsGeometryValidationService::cancelTopologyCheck( QgsVectorLayer *layer )

0 comments on commit dfe788e

Please sign in to comment.
You can’t perform that action at this time.