Skip to content

Commit 21df625

Browse files
committed
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.
1 parent b8fd1fd commit 21df625

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/app/qgisapp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,6 +5191,9 @@ bool QgisApp::addProject( const QString &projectFile )
51915191
// close the previous opened project if any
51925192
closeProject();
51935193

5194+
bool autoSetupOnFirstLayer = mLayerTreeCanvasBridge->autoSetupOnFirstLayer();
5195+
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( false );
5196+
51945197
if ( !QgsProject::instance()->read( projectFile ) )
51955198
{
51965199
QString backupFile = projectFile + "~";
@@ -5307,6 +5310,9 @@ bool QgisApp::addProject( const QString &projectFile )
53075310

53085311
QApplication::restoreOverrideCursor();
53095312

5313+
if ( autoSetupOnFirstLayer )
5314+
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( true );
5315+
53105316
mMapCanvas->freeze( false );
53115317
mMapCanvas->refresh();
53125318

0 commit comments

Comments
 (0)