Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 21df625
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -5191,6 +5191,9 @@ bool QgisApp::addProject( const QString &projectFile )
// close the previous opened project if any
closeProject();

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

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

QApplication::restoreOverrideCursor();

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

mMapCanvas->freeze( false );
mMapCanvas->refresh();

Expand Down

0 comments on commit 21df625

Please sign in to comment.