summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-18 01:57:13 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-18 01:57:13 +0100
commit2338bc9f493a8bc2e3a7b33b90cb6a633b28e7ff (patch)
tree7ebc78704d6217a0ea22d21fe7b5f710743fde75
parent5355ca1cef56a8f40937ec26c1d029ed5969a5f8 (diff)
downloadtsp-2338bc9f493a8bc2e3a7b33b90cb6a633b28e7ff.tar.gz
tsp-2338bc9f493a8bc2e3a7b33b90cb6a633b28e7ff.tar.bz2
* Make sure the runner thread gets correctly halted upon exit
-rwxr-xr-xtsp.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tsp.py b/tsp.py
index dbdefb9..3a0aa42 100755
--- a/tsp.py
+++ b/tsp.py
@@ -639,6 +639,16 @@ class AlgoGui (gtk.Window):
self.resume_button.set_sensitive (True)
self.stop_button.set_sensitive (False)
+ def halt (self):
+ '''Final halt'''
+ if self.thread:
+ self.thread.stop ()
+ self.thread.join (0.1)
+ if self.thread.isAlive ():
+ gobject.timeout_add (100, self.halt)
+ return
+ gtk.main_quit ()
+
def update_best (self, length, time):
'''Update best solution length label'''
if not length:
@@ -667,4 +677,9 @@ if __name__ == "__main__":
gtk.main ()
except KeyboardInterrupt:
pass
- gui.stop ()
+ gui.hide ()
+ gobject.timeout_add (100, gui.halt)
+ try:
+ gtk.main ()
+ except KeyboardInterrupt:
+ pass