Commit fc56b100bc9c5fa39cb4de18fdd26f4a58c6617f
1 parent
fecdb287
Exists in
master
Error handling to prevent freeze
tested on windows host
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
@@ -77,8 +77,14 @@ class Plot(pyglet.window.Window): | @@ -77,8 +77,14 @@ class Plot(pyglet.window.Window): | ||
77 | 77 | ||
78 | def on_resize(self, width, height): | 78 | def on_resize(self, width, height): |
79 | """Handle a resize event from the pyglet event loop""" | 79 | """Handle a resize event from the pyglet event loop""" |
80 | - self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))), | 80 | + try: |
81 | + self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))), | ||
81 | (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1])))) | 82 | (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1])))) |
83 | + except Exception as e: | ||
84 | + logging.critical(str(e)) | ||
85 | + self.close() | ||
86 | + logging.critical('Instance closed') | ||
87 | + sys.exit() | ||
82 | self.tag_size = min(self.height*self.margins[1]*0.3,self.width*self.margins[0]*0.3) | 88 | self.tag_size = min(self.height*self.margins[1]*0.3,self.width*self.margins[0]*0.3) |
83 | # This sometimes seems to throw an error ('AttributeError: 'Plot' object has no attribute 'margins') when started for a second time from the same instance. Interesting. Causes the plot windows to freeze | 89 | # This sometimes seems to throw an error ('AttributeError: 'Plot' object has no attribute 'margins') when started for a second time from the same instance. Interesting. Causes the plot windows to freeze |
84 | pyglet.window.Window.on_resize(self, width, height) | 90 | pyglet.window.Window.on_resize(self, width, height) |