Skip to content

Commit

Permalink
Fix an instance where the status bar coordinates are incorrectly tran…
Browse files Browse the repository at this point in the history
…sformed

This can happen immediately after a project CRS change, as the last
mouse coordinates are incorrectly considered to be in the new
project CRS.
  • Loading branch information
nyalldawson committed Dec 11, 2024
1 parent 53c4089 commit 2601265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/qgsstatusbarcoordinateswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ void QgsStatusBarCoordinatesWidget::refreshMapCanvas()
void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
{
mLastCoordinate = p;
mLastCoordinateCrs = mMapCanvas->mapSettings().destinationCrs();
updateCoordinateDisplay();
}

Expand Down Expand Up @@ -431,7 +432,7 @@ void QgsStatusBarCoordinatesWidget::updateCoordinateDisplay()
if ( mLastCoordinate.isEmpty() )
mLineEdit->clear();
else
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), mLastCoordinate, mMapCanvas->mapSettings().destinationCrs(), static_cast<int>( mMousePrecisionDecimalPlaces ) ) );
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), mLastCoordinate, mLastCoordinateCrs, static_cast<int>( mMousePrecisionDecimalPlaces ) ) );

ensureCoordinatesVisible();
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsstatusbarcoordinateswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class QgsMapCanvas;

#include "qgis_app.h"
#include "qgspointxy.h"
#include "qgscoordinatereferencesystem.h"

#include <QWidget>
#include <QElapsedTimer>
Expand Down Expand Up @@ -87,6 +88,7 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
unsigned int mMousePrecisionDecimalPlaces;

QgsPointXY mLastCoordinate;
QgsCoordinateReferenceSystem mLastCoordinateCrs;

bool mIsFirstSizeChange = true;
QElapsedTimer mLastSizeChangeTimer;
Expand Down

0 comments on commit 2601265

Please sign in to comment.