Skip to content

Commit 27ab5a0

Browse files
authoredMay 6, 2017
Merge pull request #4504 from nyalldawson/project_cleanup
Cleanup project closing
2 parents 0a0c33d + fe67704 commit 27ab5a0

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4768,8 +4768,6 @@ void QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank )
47684768
closeProject();
47694769

47704770
QgsProject *prj = QgsProject::instance();
4771-
prj->clear();
4772-
47734771
prj->layerTreeRegistryBridge()->setNewLayersVisible( settings.value( QStringLiteral( "qgis/new_layers_visible" ), true ).toBool() );
47744772

47754773
//set the color for selections
@@ -8737,11 +8735,6 @@ void QgisApp::removingLayers( const QStringList &layers )
87378735
}
87388736
}
87398737

8740-
void QgisApp::removeAllLayers()
8741-
{
8742-
QgsProject::instance()->removeAllMapLayers();
8743-
}
8744-
87458738
void QgisApp::removeLayer()
87468739
{
87478740
if ( !mLayerTreeView )
@@ -10032,7 +10025,7 @@ void QgisApp::closeProject()
1003210025
mMapCanvas->clearCache();
1003310026
mOverviewCanvas->setLayers( QList<QgsMapLayer *>() );
1003410027
mMapCanvas->freeze( false );
10035-
removeAllLayers();
10028+
QgsProject::instance()->clear();
1003610029
}
1003710030

1003810031

‎src/app/qgisapp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
206206

207207
//! Set the extents of the map canvas
208208
void setExtent( const QgsRectangle &rect );
209-
//! Remove all layers from the map and legend - reimplements same method from qgisappbase
210-
void removeAllLayers();
211209

212210
/** Open a raster or vector file; ignore other files.
213211
Used to process a commandline argument, FileOpen or Drop event.

‎src/core/qgsproject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,11 @@ QgsProject::QgsProject( QObject *parent )
348348

349349
QgsProject::~QgsProject()
350350
{
351+
clear();
351352
delete mBadLayerHandler;
352353
delete mRelationManager;
353354
delete mLayerTreeRegistryBridge;
354355
delete mRootGroup;
355-
356-
removeAllMapLayers();
357356
}
358357

359358

@@ -487,6 +486,7 @@ void QgsProject::clear()
487486
writeEntry( QStringLiteral( "Measurement" ), QStringLiteral( "/DistanceUnits" ), s.value( QStringLiteral( "/qgis/measure/displayunits" ) ).toString() );
488487
writeEntry( QStringLiteral( "Measurement" ), QStringLiteral( "/AreaUnits" ), s.value( QStringLiteral( "/qgis/measure/areaunits" ) ).toString() );
489488

489+
removeAllMapLayers();
490490
setDirty( false );
491491
}
492492

0 commit comments

Comments
 (0)
Please sign in to comment.