Skip to content
Browse files
Fix incorrect project CRS when loading project (fix #16149)
This commit fixes a situation where loading a project results
in incorrect project & canvas CRS. The bug is trigerred whenever
something in the project load calls a processEvents() call, eg
restoring a project with layer count enabled on a layer
or with a composer html item.

When this occurs, the "auto-set CRS to first added layer" code
would kick in early and replace the project's CRS with that
of the first layer loaded.

To avoid this disable the "auto-set CRS" code when loading
layers from a project.
  • Loading branch information
nyalldawson committed Mar 22, 2017
1 parent b8fd1fd commit 21df6252f05ff25518ec55757b323e3bf707f345
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/app/qgisapp.cpp
@@ -5191,6 +5191,9 @@ bool QgisApp::addProject( const QString &projectFile )
// close the previous opened project if any

bool autoSetupOnFirstLayer = mLayerTreeCanvasBridge->autoSetupOnFirstLayer();
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( false );

if ( !QgsProject::instance()->read( projectFile ) )
QString backupFile = projectFile + "~";
@@ -5307,6 +5310,9 @@ bool QgisApp::addProject( const QString &projectFile )


if ( autoSetupOnFirstLayer )
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( true );

mMapCanvas->freeze( false );

0 comments on commit 21df625

Please sign in to comment.