From 681074bf25c9f71e427e097c9b08d70937540ff6 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 22 May 2018 10:48:46 +1000 Subject: [PATCH] Setting crs for extent group box shouldn't auto check the box Causes e.g. changing the destination CRS in the save vector file dialog to accidentally enable the "extent" filter option. Refs #18977 --- src/gui/qgsextentgroupbox.cpp | 3 +++ tests/src/python/test_qgsextentgroupbox.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/gui/qgsextentgroupbox.cpp b/src/gui/qgsextentgroupbox.cpp index d5d77db6a04a..1a39ccc34d68 100644 --- a/src/gui/qgsextentgroupbox.cpp +++ b/src/gui/qgsextentgroupbox.cpp @@ -78,6 +78,7 @@ void QgsExtentGroupBox::setOutputCrs( const QgsCoordinateReferenceSystem &output { if ( mOutputCrs != outputCrs ) { + bool prevExtentEnabled = isChecked(); switch ( mExtentState ) { case CurrentExtent: @@ -116,6 +117,8 @@ void QgsExtentGroupBox::setOutputCrs( const QgsCoordinateReferenceSystem &output break; } + if ( !prevExtentEnabled ) + setChecked( false ); } } diff --git a/tests/src/python/test_qgsextentgroupbox.py b/tests/src/python/test_qgsextentgroupbox.py index c786093a7dbc..49627e62e60a 100644 --- a/tests/src/python/test_qgsextentgroupbox.py +++ b/tests/src/python/test_qgsextentgroupbox.py @@ -86,6 +86,15 @@ def test_SettingExtent(self): def testSetOutputCrs(self): w = qgis.gui.QgsExtentGroupBox() + w.setCheckable(True) + + # ensure setting output crs doesn't change state of group box + w.setChecked(False) + w.setOutputCrs(QgsCoordinateReferenceSystem('epsg:4326')) + self.assertFalse(w.isChecked()) + w.setChecked(True) + w.setOutputCrs(QgsCoordinateReferenceSystem('epsg:4326')) + self.assertTrue(w.isChecked()) w.setOutputCrs(QgsCoordinateReferenceSystem('epsg:4326')) w.setCurrentExtent(QgsRectangle(1, 2, 3, 4), QgsCoordinateReferenceSystem('epsg:4326'))