Skip to content

Commit 0afc88e

Browse files
committed
Make sure main canvas is always synced to project CRS (part 1)
Fix #16337
1 parent 1aee424 commit 0afc88e

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

src/app/qgisapp.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,9 +2840,14 @@ void QgisApp::setupConnections()
28402840
connect( mMapCanvas, &QgsMapCanvas::keyPressed,
28412841
this, &QgisApp::mapCanvas_keyPressed );
28422842

2843-
// connect renderer
2844-
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged,
2845-
this, &QgisApp::destinationCrsChanged );
2843+
// project crs connections
2844+
connect( QgsProject::instance(), &QgsProject::crsChanged,
2845+
this, &QgisApp::updateCrsStatusBar );
2846+
connect( QgsProject::instance(), &QgsProject::crsChanged,
2847+
this, [ = ]
2848+
{
2849+
mMapCanvas->setDestinationCrs( QgsProject::instance()->crs() );
2850+
} );
28462851

28472852
// connect legend signals
28482853
connect( mLayerTreeView, SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
@@ -4626,13 +4631,10 @@ void QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank )
46264631
// set project CRS
46274632
QString defCrs = settings.value( QStringLiteral( "Projections/projectDefaultCrs" ), GEO_EPSG_CRS_AUTHID ).toString();
46284633
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( defCrs );
4629-
mMapCanvas->setDestinationCrs( srs );
46304634
// write the projections _proj string_ to project settings
46314635
prj->setCrs( srs );
46324636
prj->setDirty( false );
46334637

4634-
updateCrsStatusBar();
4635-
46364638
/** New Empty Project Created
46374639
(before attempting to load custom project templates/filepaths) */
46384640

@@ -8791,7 +8793,6 @@ void QgisApp::setProjectCrsFromLayer()
87918793

87928794
QgsCoordinateReferenceSystem crs = mLayerTreeView->currentLayer()->crs();
87938795
mMapCanvas->freeze();
8794-
mMapCanvas->setDestinationCrs( crs );
87958796
QgsProject::instance()->setCrs( crs );
87968797
mMapCanvas->freeze( false );
87978798
mMapCanvas->refresh();
@@ -10316,11 +10317,6 @@ void QgisApp::updateCrsStatusBar()
1031610317
}
1031710318
}
1031810319

10319-
void QgisApp::destinationCrsChanged()
10320-
{
10321-
updateCrsStatusBar();
10322-
}
10323-
1032410320
// slot to update the progress bar in the status bar
1032510321
void QgisApp::showProgress( int progress, int totalSteps )
1032610322
{

src/app/qgisapp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12041204
void displayMessage( const QString &title, const QString &message, QgsMessageBar::MessageLevel level );
12051205
void removeMapToolMessage();
12061206
void updateMouseCoordinatePrecision();
1207-
void destinationCrsChanged();
12081207
// void debugHook();
12091208
//! Add a Layer Definition file
12101209
void addLayerDefinition();
@@ -1396,6 +1395,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
13961395

13971396
void annotationCreated( QgsAnnotation *annotation );
13981397

1398+
void updateCrsStatusBar();
1399+
13991400
signals:
14001401

14011402
/** Emitted when a key is pressed and we want non widget sublasses to be able
@@ -1531,7 +1532,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
15311532
void createOverview();
15321533
void createCanvasTools();
15331534
void createMapTips();
1534-
void updateCrsStatusBar();
15351535
void createDecorations();
15361536

15371537
//! Do histogram stretch for singleband gray / multiband color rasters

src/app/qgsprojectproperties.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ void QgsProjectProperties::apply()
734734
{
735735
QgsCoordinateReferenceSystem srs = projectionSelector->crs();
736736
QgsProject::instance()->setCrs( srs );
737-
mMapCanvas->setDestinationCrs( srs );
738737
if ( srs.isValid() )
739738
{
740739
QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );

src/gui/layertree/qgslayertreemapcanvasbridge.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()
170170

171171
if ( mFirstCRS.isValid() && firstLayers )
172172
{
173-
mCanvas->setDestinationCrs( mFirstCRS );
174173
QgsProject::instance()->setCrs( mFirstCRS );
175174
}
176175

0 commit comments

Comments
 (0)