Skip to content
Permalink
Browse files
Merge pull request #382 from dakcarto/iface_edits-tool-switch-fix_1
Fix #6968, saving/rollbacking edits deselects current editing tool
  • Loading branch information
dakcarto committed Jan 12, 2013
2 parents 971c7b8 + 8803a00 commit a3f5cea2a86cb32354545f503edf07687b8a2936
Showing with 17 additions and 1 deletion.
  1. +12 −1 src/app/qgisapp.cpp
  2. +5 −0 src/app/qgisapp.h
@@ -515,6 +515,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
updateRecentProjectPaths();
updateProjectFromTemplates();
legendLayerSelectionChanged();
mSaveRollbackInProgress = false;
activateDeactivateLayerRelatedActions( NULL );

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

if ( vlayer == activeLayer() )
mSaveRollbackInProgress = true;

if ( !vlayer->commitChanges() )
{
mSaveRollbackInProgress = false;
QMessageBox::information( 0,
tr( "Error" ),
tr( "Could not commit changes to layer %1\n\nErrors: %2\n" )
@@ -5275,8 +5280,12 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
if ( !vlayer || !vlayer->isEditable() )
return;

if ( vlayer == activeLayer() && leaveEditable )
mSaveRollbackInProgress = true;

if ( !vlayer->rollBack() )
{
mSaveRollbackInProgress = false;
QMessageBox::information( 0,
tr( "Error" ),
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
@@ -7314,6 +7323,7 @@ void QgisApp::layerEditStateChanged()
if ( layer && layer == activeLayer() )
{
activateDeactivateLayerRelatedActions( layer );
mSaveRollbackInProgress = false;
}
}

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

if ( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
if ( !vlayer->isEditable() && mMapCanvas->mapTool()
&& mMapCanvas->mapTool()->isEditTool() && !mSaveRollbackInProgress )
{
mMapCanvas->setMapTool( mNonEditMapTool );
}
@@ -1284,6 +1284,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//!flag to indicate that the previous screen mode was 'maximised'
bool mPrevScreenModeMaximized;

/** Flag to indicate an edits save/rollback for active layer is in progress
* @note added in QGIS 1.9
*/
bool mSaveRollbackInProgress;

QgsPythonUtils* mPythonUtils;

static QgisApp *smInstance;

0 comments on commit a3f5cea

Please sign in to comment.