Commit 0231fbae authored by Maxime Perrotin's avatar Maxime Perrotin

Fix segfaults due to Qt bug 18616

calls to setParentItem make Qt crash if the new parent is not in the
same scene as the item.
parent dbb88b73
......@@ -552,8 +552,10 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
# that all children items are moved together with their
# parent. Unfortunately calls to setParentItem provoke
# a segfault. To be tried again when PySide is fixed...
#each.setParent(symb)
scene.addItem(each)
# Update (04/2019) Workaround found (see sdlSymbols.py)
if symb.scene() != each.scene():
symb.scene().addItem(each)
each.setParent(symb)
each.position += deltapos
each.setZValue(each.zValue() + symb.zValue() + 1)
......
......@@ -378,6 +378,15 @@ class Decision(VerticalSymbol):
isinstance(c, Connection) and not
isinstance(c.child, (Comment, HorizontalSymbol)))
# Don't set parent item to None to avoid Qt segfault
# The bug with setParentItem is a Qt bug documented here:
# https://bugreports.qt.io/browse/QTBUG-18616
# the crash may happen if the scene of the new parent
# is different from the scene of the object. the doc says
# it is allowed but an assert in the code makes it crash
# workaround: first put the item manually in the right scene
# then call setParentItem
if self.scene() != last_cnx.scene():
self.scene().addItem(last_cnx)
last_cnx.setParentItem(self)
except ValueError:
pass
......@@ -385,6 +394,8 @@ class Decision(VerticalSymbol):
branch.boundingRect() |
branch.childrenBoundingRect()).height()
try:
if last.scene() != last_cnx.scene():
last.scene().addItem(last_cnx) # workaround Qt's bug 18616
last_cnx.setParentItem(last)
except AttributeError:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment