Skip to content

Commit e1072e9

Browse files
committed
[processing] added missing validators for param values in modeler
1 parent 4751b70 commit e1072e9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

python/plugins/processing/gui/wrappers.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def setValue(self, value):
501501
if self.dialogType == DIALOG_STANDARD:
502502
pass # TODO
503503
elif self.dialogType == DIALOG_BATCH:
504-
return self.widget.setText(value)
504+
self.widget.setText(value)
505505
else:
506506
self.setComboValue(value)
507507

@@ -511,7 +511,9 @@ def value(self):
511511
elif self.dialogType == DIALOG_BATCH:
512512
return self.widget.getText()
513513
else:
514-
return self.comboValue()
514+
def validator(v):
515+
return bool(v) or self.param.optional
516+
return self.comboValue(validator)
515517

516518

517519
class SelectionWidgetWrapper(WidgetWrapper):
@@ -568,7 +570,7 @@ def setValue(self, value):
568570
if self.dialogType == DIALOG_STANDARD:
569571
pass # TODO
570572
elif self.dialogType == DIALOG_BATCH:
571-
return self.widget.setText(value)
573+
self.widget.setText(value)
572574
else:
573575
self.setComboValue(value)
574576

@@ -582,7 +584,9 @@ def value(self):
582584
elif self.dialogType == DIALOG_BATCH:
583585
return self.widget.getText()
584586
else:
585-
return self.comboValue()
587+
def validator(v):
588+
return bool(v) or self.param.optional
589+
return self.comboValue(validator)
586590

587591
class StringWidgetWrapper(WidgetWrapper):
588592

@@ -702,9 +706,10 @@ def value(self):
702706
elif self.dialogType == DIALOG_BATCH:
703707
return self.widget.getText()
704708
else:
705-
return self.comboValue()
706-
707-
709+
def validator(v):
710+
return bool(v) or self.param.optional
711+
return self.comboValue(validator)
712+
708713
class TableFieldWidgetWrapper(WidgetWrapper):
709714

710715
NOT_SET = '[Not set]'
@@ -801,8 +806,10 @@ def value(self):
801806
elif self.dialogType == DIALOG_BATCH:
802807
return self.widget.text()
803808
else:
804-
return self.comboValue()
805-
809+
def validator(v):
810+
return bool(v) or self.param.optional
811+
return self.comboValue(validator)
812+
806813
def anotherParameterWidgetHasChanged(self,wrapper):
807814
if wrapper.param.name == self.param.parent:
808815
layer = wrapper.value()

0 commit comments

Comments
 (0)