diff options
author | Volker Schroer <3470424+dl1ksv@users.noreply.github.com> | 2021-05-17 11:09:32 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-06-01 09:20:33 -0400 |
commit | e562d6b3c82a30f12b4e8e2585447dddeb88e93d (patch) | |
tree | fc11e901d912690540f363d2bd13a5bfd593c4c5 /grc/gui | |
parent | d3dc106719fa01f6432b3bafc839dc455f61d695 (diff) |
grc: handle variables of type raw correctly
At the moment grc does not validate variables, as they are of type raw.
So they are always treated as valid, which leads to some problems, see: #4519.
A approach to fix #4519 is #4531.
This approach improves the situation, but has still some problems.
param.py provides a validator function for dtype raw, but this is not used, as dtypes.py provides no validator function for dtype raw.
This fix clears the error messages in base.rewrite not in base.elements.validate, so the error messages are kept.
In addition this makes it possible, to make the code in VariableEditor.py smoother.
The error messages are kept on switching the different tabs in VariableEditor.
Signed-off-by: Volker Schroer <3470424+dl1ksv@users.noreply.github.com>
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/VariableEditor.py | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/grc/gui/VariableEditor.py b/grc/gui/VariableEditor.py index d815e5ddd1..afffc22008 100644 --- a/grc/gui/VariableEditor.py +++ b/grc/gui/VariableEditor.py @@ -180,21 +180,7 @@ class VariableEditor(Gtk.VBox): else: # Evaluate and show the value (if it is a variable) if block.is_variable: - # Evaluate the params - for key in block.params: - evaluated = str(block.params[key].evaluate()) - # ensure that evaluated is a UTF-8 string - # Old PMTs could produce non-UTF-8 strings - evaluated = evaluated.encode('utf-8', 'backslashreplace').decode('utf-8') - self.set_tooltip_text(evaluated) - - # Evaluate the block value - try: - evaluated = str(eval(block.value, block.parent.namespace, block.namespace)) - self.set_tooltip_text(evaluated) - except Exception as error: - self.set_tooltip_text(str(error)) - pass + value = str(block.evaluate(block.value)) # Always set the text value. sp('text', value) |