Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simuDAtor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
simuDAtor
Commits
0cdae997
Commit
0cdae997
authored
10 months ago
by
Martin
Browse files
Options
Downloads
Patches
Plain Diff
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
!36
Grx displays error message instead of crashing
Pipeline
#133073
failed
10 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/simudator/gui/module_graphics_item/module_graphics_item.py
+15
-0
15 additions, 0 deletions
...imudator/gui/module_graphics_item/module_graphics_item.py
with
15 additions
and
0 deletions
src/simudator/gui/module_graphics_item/module_graphics_item.py
+
15
−
0
View file @
0cdae997
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment