Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a3f5cea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -515,6 +515,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
updateRecentProjectPaths();
updateProjectFromTemplates();
legendLayerSelectionChanged();
mSaveRollbackInProgress = false;
activateDeactivateLayerRelatedActions( NULL );

addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
Expand Down Expand Up @@ -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" )
Expand All @@ -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" )
Expand Down Expand Up @@ -7314,6 +7323,7 @@ void QgisApp::layerEditStateChanged()
if ( layer && layer == activeLayer() )
{
activateDeactivateLayerRelatedActions( layer );
mSaveRollbackInProgress = false;
}
}

Expand Down Expand Up @@ -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 );
}
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -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;
Expand Down

0 comments on commit a3f5cea

Please sign in to comment.