summaryrefslogtreecommitdiffstats
path: root/pyanaconda/exception.py
diff options
context:
space:
mode:
authorVratislav Podzimek <vpodzime@redhat.com>2012-08-27 15:39:45 +0200
committerVratislav Podzimek <vpodzime@redhat.com>2012-08-29 11:16:13 +0200
commit0573968bec32fdda26633818118730a5d2333da8 (patch)
treea5055be74f02d2af591c3fac782d363112c6f5da /pyanaconda/exception.py
parent83190cf463b7158a2a6295e3f5ad47bb857b809a (diff)
downloadanaconda-0573968bec32fdda26633818118730a5d2333da8.tar.gz
anaconda-0573968bec32fdda26633818118730a5d2333da8.tar.xz
anaconda-0573968bec32fdda26633818118730a5d2333da8.zip
Use Gtk.main_level() to check if main loop is already running
For some reason GLib.main_depth() stopped working and returns 0 even if Gtk.main loop is already running. This leads to crashes and hangs of whole GUI when exception appears in a thread different from the main one. Resolves: rhbz#849997
Diffstat (limited to 'pyanaconda/exception.py')
-rw-r--r--pyanaconda/exception.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index 2ac513ba9..165deed5c 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -66,12 +66,22 @@ class AnacondaExceptionHandler(ExceptionHandler):
self.intf.showError(hw_error_msg)
sys.exit(0)
else:
- if GLib.main_depth() > 0:
- # main loop is running, don't crash it by running another one
- # potentially from a different thread
- GLib.idle_add(run_handleException_on_idle,
- ((ty, value, tb), obj))
- else:
+ try:
+ from gi.repository import Gtk
+
+ if Gtk.main_level() > 0:
+ # main loop is running, don't crash it by running another one
+ # potentially from a different thread
+ GLib.idle_add(run_handleException_on_idle,
+ ((ty, value, tb), obj))
+ else:
+ super(AnacondaExceptionHandler, self).handleException(
+ (ty, value, tb), obj)
+
+ except RuntimeError:
+ # X not running (Gtk cannot be initialized)
+ print "An unknown error has occured, look at the "\
+ "/tmp/anaconda-tb* file(s) for more details"
super(AnacondaExceptionHandler, self).handleException(
(ty, value, tb), obj)