[PATCH] Check that Gtk.main is not already running before starting another one

Vratislav Podzimek vpodzime at redhat.com
Tue Aug 7 13:03:18 UTC 2012


If python-meh catches an exception from a different thread before
GraphicalUserInterface's Gtk main loop is running, it runs its own
loop. Running another one from a different thread would cause Gtk
crash. So lets juts wait for the reboot.
---
 pyanaconda/ui/gui/__init__.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 5887047..15f82b8 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -18,7 +18,7 @@
 #
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
 #
-import importlib, inspect, os, sys
+import importlib, inspect, os, sys, time
 import meh.ui.gui
 
 from pyanaconda.ui import UserInterface
@@ -87,6 +87,16 @@ class GraphicalUserInterface(UserInterface):
     def run(self):
         from gi.repository import Gtk
 
+        if Gtk.main_level() > 0:
+            # Gtk main loop running. That means python-meh caught exception
+            # and runs its main loop. Do not crash Gtk by running another one
+            # from a different thread and just wait until python-meh is
+            # finished, then quit.
+            while Gtk.main_level() > 0:
+                time.sleep(2)
+
+            sys.exit(0)
+
         from pyanaconda.product import isFinal, productName, productVersion
 
         # If we set these values on the very first window shown, they will get
-- 
1.7.11.2



More information about the anaconda-patches mailing list