From f38b7359557a32be749782cd0df07407f37f03cb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 8 Nov 2023 08:59:48 +1000 Subject: [PATCH] Fix exception in interpolation algorithm widgets Fixes #55138 --- .../processing/algs/qgis/ui/HeatmapWidgets.py | 9 ++++++--- .../algs/qgis/ui/InterpolationWidgets.py | 14 ++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/python/plugins/processing/algs/qgis/ui/HeatmapWidgets.py b/python/plugins/processing/algs/qgis/ui/HeatmapWidgets.py index 2302c7108ddd8..d13aa556f22f5 100644 --- a/python/plugins/processing/algs/qgis/ui/HeatmapWidgets.py +++ b/python/plugins/processing/algs/qgis/ui/HeatmapWidgets.py @@ -99,8 +99,9 @@ def recalculate_bounds(self): def pixelSizeChanged(self): cell_size = self.mCellXSpinBox.value() - if cell_size <= 0: + if cell_size <= 0 or self.raster_bounds.isNull(): return + self.mCellYSpinBox.blockSignals(True) self.mCellYSpinBox.setValue(cell_size) self.mCellYSpinBox.blockSignals(False) @@ -115,8 +116,9 @@ def pixelSizeChanged(self): def rowsChanged(self): rows = self.mRowsSpinBox.value() - if rows <= 0: + if rows <= 0 or self.raster_bounds.isNull(): return + cell_size = self.raster_bounds.height() / rows cols = max(round(self.raster_bounds.width() / cell_size) + 1, 1) self.mColumnsSpinBox.blockSignals(True) @@ -129,8 +131,9 @@ def rowsChanged(self): def columnsChanged(self): cols = self.mColumnsSpinBox.value() - if cols < 2: + if cols < 2 or self.raster_bounds.isNull(): return + cell_size = self.raster_bounds.width() / (cols - 1) rows = max(round(self.raster_bounds.height() / cell_size), 1) self.mRowsSpinBox.blockSignals(True) diff --git a/python/plugins/processing/algs/qgis/ui/InterpolationWidgets.py b/python/plugins/processing/algs/qgis/ui/InterpolationWidgets.py index eeae50873aecc..2f1bb2e9f2a16 100644 --- a/python/plugins/processing/algs/qgis/ui/InterpolationWidgets.py +++ b/python/plugins/processing/algs/qgis/ui/InterpolationWidgets.py @@ -280,11 +280,7 @@ def setLayers(self, layersData: str): layer = QgsProcessingUtils.variantToSource(v[0], self.context) if layer: self.layers.append(layer) - bbox = layer.sourceExtent() - if self.extent.isEmpty(): - self.extent = bbox - else: - self.extent.combineExtentWith(bbox) + self.extent.combineExtentWith(layer.sourceExtent()) self.pixelSizeChanged() @@ -307,7 +303,7 @@ def setExtent(self, extent: Optional[str]): def pixelSizeChanged(self): cell_size = self.mCellXSpinBox.value() - if cell_size <= 0: + if cell_size <= 0 or self.extent.isNull(): return self.mCellYSpinBox.blockSignals(True) @@ -324,8 +320,9 @@ def pixelSizeChanged(self): def rowsChanged(self): rows = self.mRowsSpinBox.value() - if rows <= 0: + if rows <= 0 or self.extent.isNull(): return + cell_size = self.extent.height() / rows cols = max(round(self.extent.width() / cell_size) + 1, 1) self.mColumnsSpinBox.blockSignals(True) @@ -338,8 +335,9 @@ def rowsChanged(self): def columnsChanged(self): cols = self.mColumnsSpinBox.value() - if cols < 2: + if cols < 2 or self.extent.isNull(): return + cell_size = self.extent.width() / (cols - 1) rows = max(round(self.extent.height() / cell_size), 1) self.mRowsSpinBox.blockSignals(True)