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
72abb33c
Commit
72abb33c
authored
10 months ago
by
Martin Högstedt
Browse files
Options
Downloads
Plain Diff
Merge branch '58-grx-craches-when-inputing-incorrect-data-in-edit-module-state' into 'main'
Grx displays error message instead of crashing Closes
#58
See merge request
!36
parents
a61ebd64
46757a0e
No related branches found
No related tags found
1 merge request
!36
Grx displays error message instead of crashing
Pipeline
#133128
failed
10 months ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/simudator/gui/module_graphics_item/module_graphics_item.py
+24
-0
24 additions, 0 deletions
...imudator/gui/module_graphics_item/module_graphics_item.py
src/simudator/processor/mia/gui/mia_grx_graphic.py
+7
-2
7 additions, 2 deletions
src/simudator/processor/mia/gui/mia_grx_graphic.py
with
31 additions
and
2 deletions
src/simudator/gui/module_graphics_item/module_graphics_item.py
+
24
−
0
View file @
72abb33c
...
...
@@ -6,6 +6,7 @@ from qtpy.QtCore import Slot
from
qtpy.QtGui
import
QCursor
from
qtpy.QtWidgets
import
(
QAction
,
QErrorMessage
,
QGraphicsItem
,
QGraphicsObject
,
QGraphicsRectItem
,
...
...
@@ -46,6 +47,8 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem):
# Save module for later updates
self
.
module
=
module
self
.
errorMessageWidget
=
QErrorMessage
()
# Use modules name if no name is given
if
name
is
None
:
self
.
name
=
self
.
module
.
name
...
...
@@ -185,8 +188,29 @@ 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
if
isinstance
(
parsed_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.
src/simudator/processor/mia/gui/mia_grx_graphic.py
+
7
−
2
View file @
72abb33c
...
...
@@ -3,6 +3,7 @@ import math
from
qtpy.QtCore
import
QPointF
from
qtpy.QtGui
import
QPolygonF
from
qtpy.QtWidgets
import
(
QErrorMessage
,
QGraphicsLineItem
,
QGraphicsPolygonItem
,
QGraphicsRectItem
,
...
...
@@ -126,14 +127,18 @@ class GrxGraphicsItem(ModuleGraphicsItem):
)
# Add ports to and from bus
from_bus_port
=
PortGraphicsItem
(
self
.
module
.
signals
[
"
in_input
"
],
Orientation
.
RIGHT
,
self
)
from_bus_port
=
PortGraphicsItem
(
self
.
module
.
signals
[
"
in_input
"
],
Orientation
.
RIGHT
,
self
)
from_bus_port
.
setPos
(
rect_width
+
self
.
LINE_LENGTH
+
self
.
MUX_WIDTH
,
# Use the buses port margins so the ports align nicely
mux_height
/
2
-
BusGraphicsItem
.
PORT_MARGIN
/
2
,
)
to_bus_port
=
PortGraphicsItem
(
self
.
module
.
signals
[
"
out_content
"
],
Orientation
.
RIGHT
,
self
)
to_bus_port
=
PortGraphicsItem
(
self
.
module
.
signals
[
"
out_content
"
],
Orientation
.
RIGHT
,
self
)
to_bus_port
.
setPos
(
rect_width
+
self
.
LINE_LENGTH
+
self
.
MUX_WIDTH
,
# Use the buses port margins so the ports align nicely
...
...
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