Skip to content

Commit

Permalink
App: fix performance issue when closing a project with a lot of layers
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and nyalldawson committed Oct 21, 2022
1 parent f7c58a5 commit b289051
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -14201,6 +14201,10 @@ void QgisApp::closeProject()
// Avoid unnecessary layer changed handling for each layer removed - instead,
// defer the handling until we've removed all layers
mBlockActiveLayerChanged = true;
// Explicitly unset the selection in the layer tree view, otherwise we get
// bad performance when the project has a big number of layers, which causes
// the current index to be changed many times.
mLayerTreeView->setCurrentIndex( QModelIndex() );
QgsProject::instance()->clear();
mBlockActiveLayerChanged = false;

Expand Down

0 comments on commit b289051

Please sign in to comment.