Skip to content
Snippets Groups Projects
Commit 0cdae997 authored by Martin's avatar Martin
Browse files

grx will no longer crash when a string is entered in the edit module state dialog

parent 3057e026
No related branches found
No related tags found
1 merge request!36Grx displays error message instead of crashing
Pipeline #133073 failed
......@@ -183,12 +183,27 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem):
"""
try:
parsed_value = ast.literal_eval(value)
# ast.literal_eval only raises an error the the
# parsed value isn't a valid data type.
# If the user edits GRX and enters a string "a"
# it will crash
if isinstance(parsed_value, list):
for value in parsed_value:
if isinstance(value, str):
raise TypeError
except SyntaxError as e:
self.errorMessageWidget.showMessage(str(e))
except ValueError as e:
self.errorMessageWidget.showMessage(
"Value Error. Unable to parse input. Make sure it is in the correct base."
)
except TypeError as e:
self.errorMessageWidget.showMessage(
"Type Error. Unable to parse input. Make sure it is the correct type."
)
else:
module_state = self.module.get_state()
module_state[state] = parsed_value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment