Skip to content

Commit

Permalink
No unique connections on lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 36e83f3 commit dfe788e
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions src/app/qgsgeometryvalidationservice.cpp
Expand Up @@ -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]()
{
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit dfe788e

Please sign in to comment.