[gnome-music/wip/merge: 138/343] Quit GTK if unhandled exception occurs



commit 6bb686f5982b5f5079da7b1172b04f3f416027c0
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Mon Jul 15 20:24:21 2013 +0200

    Quit GTK if unhandled exception occurs

 gnome-music.in |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gnome-music.in b/gnome-music.in
index c1dcd34..eae6c8d 100644
--- a/gnome-music.in
+++ b/gnome-music.in
@@ -1,12 +1,24 @@
 #!/usr/bin/env python3
 
 import sys, signal
-from gi.repository import Gio
+from gi.repository import Gio, Gtk
 sys.path.insert(1, '@pythondir@')
 
 from gnomemusic.application import Application
 
+def install_excepthook():
+    """ Make sure we exit when an unhandled exception occurs. """
+    old_hook = sys.excepthook
+    def new_hook(etype, evalue, etb):
+        old_hook(etype, evalue, etb)
+        while Gtk.main_level():
+            Gtk.main_quit()
+        sys.exit()
+    sys.excepthook = new_hook
+
 if __name__ == "__main__":
+    install_excepthook()
+
     # We use our own libgd.so, so let gi.repository find it
     from gi.repository import GIRepository
     GIRepository.Repository.prepend_search_path('@libdir@/gnome-music')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]