Commit 94580040 by Maxime Perrotin

Catch exceptions when statechart can't be rendered

parent c0c8ecd9
 ... @@ -442,10 +442,14 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ... @@ -442,10 +442,14 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): # Harmonize the size of states to avoid having huge composite state(s) # Harmonize the size of states to avoid having huge composite state(s) # next to single, small states. Rule: there can't be a state with a size # next to single, small states. Rule: there can't be a state with a size # that is less than a third of the biggest state. # that is less than a third of the biggest state. min_width = float(max(node.attr.get('width', 0.0) or 0.0 try: for node in graphtree['graph'].iternodes())) min_width = float(max(node.attr.get('width', 0.0) or 0.0 min_height = float(max(node.attr.get('height', 0.0) or 0.0 for node in graphtree['graph'].iternodes())) for node in graphtree['graph'].iternodes())) min_height = float(max(node.attr.get('height', 0.0) or 0.0 for node in graphtree['graph'].iternodes())) except ValueError as err: LOG.debug(str(err)) min_width, min_height = 0, 0 if min_width and min_height: if min_width and min_height: for node in graphtree['graph'].iternodes(): for node in graphtree['graph'].iternodes(): if node.attr['shape'] != 'record': if node.attr['shape'] != 'record': ... ...
 ... @@ -2010,15 +2010,15 @@ class OG_MainWindow(QtGui.QMainWindow, object): ... @@ -2010,15 +2010,15 @@ class OG_MainWindow(QtGui.QMainWindow, object): scene = self.view.parent_scene[0][0] scene = self.view.parent_scene[0][0] else: else: scene = self.view.scene() scene = self.view.scene() graph = scene.sdl_to_statechart() try: try: graph = scene.sdl_to_statechart() Statechart.render_statechart(self.statechart_scene, Statechart.render_statechart(self.statechart_scene, graph) graph) self.statechart_view.refresh() self.statechart_view.refresh() self.statechart_view.fitInView( self.statechart_view.fitInView( self.statechart_scene.itemsBoundingRect(), self.statechart_scene.itemsBoundingRect(), Qt.KeepAspectRatioByExpanding) Qt.KeepAspectRatioByExpanding) except (IOError, TypeError) as err: except (AttributeError, IOError, TypeError) as err: LOG.debug(str(err)) LOG.debug(str(err)) @QtCore.Slot(ogAST.AST) @QtCore.Slot(ogAST.AST) ... @@ -2298,12 +2298,12 @@ def export(ast, options): ... @@ -2298,12 +2298,12 @@ def export(ast, options): # Also save the statechart view of the current scene # Also save the statechart view of the current scene LOG.info('Saving statechart sc_{}.png'.format(process.processName)) LOG.info('Saving statechart sc_{}.png'.format(process.processName)) sc_scene = SDL_Scene(context='statechart') sc_scene = SDL_Scene(context='statechart') graph = diagram.sdl_to_statechart() try: try: graph = diagram.sdl_to_statechart() Statechart.render_statechart(sc_scene, graph, Statechart.render_statechart(sc_scene, graph, dump_gfx=process.processName) dump_gfx=process.processName) sc_scene.refresh() sc_scene.refresh() except (IOError, TypeError) as err: except (AttributeError, IOError, TypeError) as err: LOG.debug(str(err)) LOG.debug(str(err)) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!