Skip to content

Commit 8803a00

Browse files
committedJan 12, 2013
Fix #6968, saving/rollbacking edits deselects current editing tool
1 parent 971c7b8 commit 8803a00

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
515515
updateRecentProjectPaths();
516516
updateProjectFromTemplates();
517517
legendLayerSelectionChanged();
518+
mSaveRollbackInProgress = false;
518519
activateDeactivateLayerRelatedActions( NULL );
519520

520521
addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
@@ -5253,8 +5254,12 @@ void QgisApp::saveEdits( QgsMapLayer *layer, bool leaveEditable )
52535254
if ( !vlayer || !vlayer->isEditable() || !vlayer->isModified() )
52545255
return;
52555256

5257+
if ( vlayer == activeLayer() )
5258+
mSaveRollbackInProgress = true;
5259+
52565260
if ( !vlayer->commitChanges() )
52575261
{
5262+
mSaveRollbackInProgress = false;
52585263
QMessageBox::information( 0,
52595264
tr( "Error" ),
52605265
tr( "Could not commit changes to layer %1\n\nErrors: %2\n" )
@@ -5275,8 +5280,12 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
52755280
if ( !vlayer || !vlayer->isEditable() )
52765281
return;
52775282

5283+
if ( vlayer == activeLayer() && leaveEditable )
5284+
mSaveRollbackInProgress = true;
5285+
52785286
if ( !vlayer->rollBack() )
52795287
{
5288+
mSaveRollbackInProgress = false;
52805289
QMessageBox::information( 0,
52815290
tr( "Error" ),
52825291
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
@@ -7314,6 +7323,7 @@ void QgisApp::layerEditStateChanged()
73147323
if ( layer && layer == activeLayer() )
73157324
{
73167325
activateDeactivateLayerRelatedActions( layer );
7326+
mSaveRollbackInProgress = false;
73177327
}
73187328
}
73197329

@@ -7454,7 +7464,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
74547464
mActionCopyFeatures->setEnabled( layerHasSelection );
74557465
mActionFeatureAction->setEnabled( layerHasActions );
74567466

7457-
if ( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
7467+
if ( !vlayer->isEditable() && mMapCanvas->mapTool()
7468+
&& mMapCanvas->mapTool()->isEditTool() && !mSaveRollbackInProgress )
74587469
{
74597470
mMapCanvas->setMapTool( mNonEditMapTool );
74607471
}

‎src/app/qgisapp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
12841284
//!flag to indicate that the previous screen mode was 'maximised'
12851285
bool mPrevScreenModeMaximized;
12861286

1287+
/** Flag to indicate an edits save/rollback for active layer is in progress
1288+
* @note added in QGIS 1.9
1289+
*/
1290+
bool mSaveRollbackInProgress;
1291+
12871292
QgsPythonUtils* mPythonUtils;
12881293

12891294
static QgisApp *smInstance;

0 commit comments

Comments
 (0)
Please sign in to comment.