Skip to content

Commit

Permalink
Stop editing before layer remove if necessary
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8205 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 11, 2008
1 parent 6961f56 commit 13fafbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/legend/qgslegendlayerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ void QgsLegendLayerFile::toggleEditing()

}

bool QgsLegendLayerFile::isEditing()
{
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(mLyr.layer());
return vlayer && vlayer->isEditable();
}

void QgsLegendLayerFile::layerNameChanged()
{
QString name = mLyr.layer()->name();
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegendlayerfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class QgsLegendLayerFile : public QgsLegendItem
/**Toggle editing for layer*/
void toggleEditing();

/**Return editing status for layer*/
bool isEditing();

/**Toggle show in overview*/
void showInOverview();

Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3774,6 +3774,11 @@ void QgisApp::inOverview()

void QgisApp::removeLayer()
{
QgsLegendLayerFile* currentLayerFile = mMapLegend->currentLayerFile();
if(currentLayerFile && currentLayerFile->isEditing() )
{
currentLayerFile->toggleEditing();
}
mMapLegend->legendLayerRemove();
}

Expand Down

0 comments on commit 13fafbb

Please sign in to comment.