Skip to content

Commit

Permalink
Merge pull request #8604 from m-kuhn/geometry-validation-reenable-lay…
Browse files Browse the repository at this point in the history
…er-savability

Save layer changes on successful repair
  • Loading branch information
m-kuhn authored Dec 6, 2018
2 parents 0983f52 + 50037a5 commit ba88a10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7125,7 +7125,6 @@ void QgisApp::commitError( QgsVectorLayer *vlayer )
const QStringList commitErrors = vlayer->commitErrors();
if ( !vlayer->allowCommit() && commitErrors.empty() )
{
QgsMessageLog::logMessage( tr( "Could not save changes. Geometry validation failed." ) );
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsgeometryvalidationservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsF

void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer )
{
if ( !mLayerChecks[layer].topologyChecks.empty() ) // TODO && topologyChecks not fulfilled
if ( !mBypassChecks && !mLayerChecks[layer].topologyChecks.empty() )
{
if ( !layer->allowCommit() )
{
Expand Down Expand Up @@ -461,7 +461,9 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer
}
if ( allErrors.empty() && mLayerChecks[layer].singleFeatureCheckErrors.empty() && mLayerChecks[layer].commitPending )
{
mBypassChecks = true;
layer->commitChanges();
mBypassChecks = false;
mMessageBar->popWidget( mMessageBarItem );
mMessageBarItem = nullptr;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsgeometryvalidationservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class QgsGeometryValidationService : public QObject
QgsMessageBar *mMessageBar = nullptr;
QgsMessageBarItem *mMessageBarItem = nullptr;

// when checks do complete successfully and changes need to be saved
// this variable is used to indicate that it's safe to bypass the checks
bool mBypassChecks = false;

};

#endif // QGSGEOMETRYVALIDATIONSERVICE_H

0 comments on commit ba88a10

Please sign in to comment.