@@ -515,6 +515,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
515
515
updateRecentProjectPaths ();
516
516
updateProjectFromTemplates ();
517
517
legendLayerSelectionChanged ();
518
+ mSaveRollbackInProgress = false ;
518
519
activateDeactivateLayerRelatedActions ( NULL );
519
520
520
521
addDockWidget ( Qt::LeftDockWidgetArea, mUndoWidget );
@@ -5253,8 +5254,12 @@ void QgisApp::saveEdits( QgsMapLayer *layer, bool leaveEditable )
5253
5254
if ( !vlayer || !vlayer->isEditable () || !vlayer->isModified () )
5254
5255
return ;
5255
5256
5257
+ if ( vlayer == activeLayer () )
5258
+ mSaveRollbackInProgress = true ;
5259
+
5256
5260
if ( !vlayer->commitChanges () )
5257
5261
{
5262
+ mSaveRollbackInProgress = false ;
5258
5263
QMessageBox::information ( 0 ,
5259
5264
tr ( " Error" ),
5260
5265
tr ( " Could not commit changes to layer %1\n\n Errors: %2\n " )
@@ -5275,8 +5280,12 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
5275
5280
if ( !vlayer || !vlayer->isEditable () )
5276
5281
return ;
5277
5282
5283
+ if ( vlayer == activeLayer () && leaveEditable )
5284
+ mSaveRollbackInProgress = true ;
5285
+
5278
5286
if ( !vlayer->rollBack () )
5279
5287
{
5288
+ mSaveRollbackInProgress = false ;
5280
5289
QMessageBox::information ( 0 ,
5281
5290
tr ( " Error" ),
5282
5291
tr ( " Could not %1 changes to layer %2\n\n Errors: %3\n " )
@@ -7314,6 +7323,7 @@ void QgisApp::layerEditStateChanged()
7314
7323
if ( layer && layer == activeLayer () )
7315
7324
{
7316
7325
activateDeactivateLayerRelatedActions ( layer );
7326
+ mSaveRollbackInProgress = false ;
7317
7327
}
7318
7328
}
7319
7329
@@ -7454,7 +7464,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
7454
7464
mActionCopyFeatures ->setEnabled ( layerHasSelection );
7455
7465
mActionFeatureAction ->setEnabled ( layerHasActions );
7456
7466
7457
- if ( !vlayer->isEditable () && mMapCanvas ->mapTool () && mMapCanvas ->mapTool ()->isEditTool () )
7467
+ if ( !vlayer->isEditable () && mMapCanvas ->mapTool ()
7468
+ && mMapCanvas ->mapTool ()->isEditTool () && !mSaveRollbackInProgress )
7458
7469
{
7459
7470
mMapCanvas ->setMapTool ( mNonEditMapTool );
7460
7471
}
0 commit comments