Skip to content

Commit c66159b

Browse files
committed
[processing] Fix warning when loading algorithm dialog and no layers
are present Fixes #21631
1 parent db75122 commit c66159b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

python/plugins/processing/gui/wrappers.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1630,12 +1630,15 @@ def setLayer(self, layer):
16301630
if isinstance(layer, QgsProcessingFeatureSourceDefinition):
16311631
layer, ok = layer.source.valueAsString(self.context.expressionContext())
16321632
if isinstance(layer, str):
1633-
layer = QgsProcessingUtils.mapLayerFromString(layer, self.context)
1634-
if not isinstance(layer, QgsVectorLayer) or not layer.isValid():
1635-
self.dialog.messageBar().clearWidgets()
1636-
self.dialog.messageBar().pushMessage("", self.tr("Could not load selected layer/table. Dependent field could not be populated"),
1637-
level=Qgis.Warning, duration=5)
1638-
return
1633+
if not layer: # empty string
1634+
layer = None
1635+
else:
1636+
layer = QgsProcessingUtils.mapLayerFromString(layer, self.context)
1637+
if not isinstance(layer, QgsVectorLayer) or not layer.isValid():
1638+
self.dialog.messageBar().clearWidgets()
1639+
self.dialog.messageBar().pushMessage("", self.tr("Could not load selected layer/table. Dependent field could not be populated"),
1640+
level=Qgis.Warning, duration=5)
1641+
return
16391642

16401643
self._layer = layer
16411644

0 commit comments

Comments
 (0)