From fc56b100bc9c5fa39cb4de18fdd26f4a58c6617f Mon Sep 17 00:00:00 2001
From: Hugo Stephens <shugo8383@gmail.com>
Date: Fri, 9 Mar 2018 10:20:59 +0000
Subject: [PATCH] Error handling to prevent freeze

---
 robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py b/robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
index 652bb28..d894e35 100755
--- a/robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
+++ b/robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
@@ -77,8 +77,14 @@ class Plot(pyglet.window.Window):
 
     def on_resize(self, width, height):
         """Handle a resize event from the pyglet event loop"""
-        self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))),
+        try:
+            self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))),
                 (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1]))))
+        except Exception as e:
+            logging.critical(str(e))
+            self.close()
+            logging.critical('Instance closed')
+            sys.exit()
         self.tag_size = min(self.height*self.margins[1]*0.3,self.width*self.margins[0]*0.3)
         # 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
         pyglet.window.Window.on_resize(self, width, height)
--
libgit2 0.21.2