Skip to content

Commit

Permalink
Display an error for exceptions during GUI setup
Browse files Browse the repository at this point in the history
Exceptions can occur between the start of GUI initialization and the Gtk
main loop, in particular if product images specify missing or bad
stylesheets. If an exception occurs in this code, the GUI must release
the GUI lock so that python-meh knows to start its own main loop.
Otherwise meh will enqueue itself in a main loop that will never be run,
and anaconda exits and reboots the system.

(cherry picked from commit 55a8cb7)
  • Loading branch information
dashea committed Mar 7, 2015
1 parent 35710e0 commit 9e090ca
Showing 1 changed file with 42 additions and 36 deletions.
78 changes: 42 additions & 36 deletions pyanaconda/ui/gui/__init__.py
Expand Up @@ -654,55 +654,61 @@ def run(self):
threads.threadMgr.wait_for_error_threads()
sys.exit(1)

# Apply a widget-scale to hidpi monitors
self._widgetScale()
try:
# Apply a widget-scale to hidpi monitors
self._widgetScale()

while not self._currentAction:
self._currentAction = self._instantiateAction(self._actions[0])
if not self._currentAction:
self._actions.pop(0)
while not self._currentAction:
self._currentAction = self._instantiateAction(self._actions[0])
if not self._currentAction:
self._actions.pop(0)

if not self._actions:
return

self._currentAction.initialize()
self._currentAction.entry_logger()
self._currentAction.refresh()
if not self._actions:
return

self._currentAction.window.set_beta(not self._isFinal)
self._currentAction.window.set_property("distribution", self._distributionText().upper())
self._currentAction.initialize()
self._currentAction.entry_logger()
self._currentAction.refresh()

# Set some program-wide settings.
settings = Gtk.Settings.get_default()
settings.set_property("gtk-font-name", "Cantarell")
settings.set_property("gtk-icon-theme-name", "gnome")
self._currentAction.window.set_beta(not self._isFinal)
self._currentAction.window.set_property("distribution", self._distributionText().upper())

# Apply the application stylesheet
provider = Gtk.CssProvider()
provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css")
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
# Set some program-wide settings.
settings = Gtk.Settings.get_default()
settings.set_property("gtk-font-name", "Cantarell")
settings.set_property("gtk-icon-theme-name", "gnome")

# Apply the installclass stylesheet
if self.instclass.stylesheet:
# Apply the application stylesheet
provider = Gtk.CssProvider()
provider.load_from_path(self.instclass.stylesheet)
provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css")
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
STYLE_PROVIDER_PRIORITY_INSTALLCLASS)
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

# Look for updates to the stylesheet and apply them at a higher priority
for updates_dir in ("updates", "product"):
updates_css = "/run/install/%s/anaconda-gtk.css" % updates_dir
if os.path.exists(updates_css):
# Apply the installclass stylesheet
if self.instclass.stylesheet:
provider = Gtk.CssProvider()
provider.load_from_path(updates_css)
provider.load_from_path(self.instclass.stylesheet)
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
STYLE_PROVIDER_PRIORITY_UPDATES)
STYLE_PROVIDER_PRIORITY_INSTALLCLASS)

self.mainWindow.setCurrentAction(self._currentAction)
# Look for updates to the stylesheet and apply them at a higher priority
for updates_dir in ("updates", "product"):
updates_css = "/run/install/%s/anaconda-gtk.css" % updates_dir
if os.path.exists(updates_css):
provider = Gtk.CssProvider()
provider.load_from_path(updates_css)
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
STYLE_PROVIDER_PRIORITY_UPDATES)

# Do this at the last possible minute.
unbusyCursor()
self.mainWindow.setCurrentAction(self._currentAction)

# Do this at the last possible minute.
unbusyCursor()
# If anything went wrong before we start the Gtk main loop, release
# the gui lock and re-raise the exception so that meh can take over
except Exception:
self._gui_lock.release()
raise

Gtk.main()

Expand Down

0 comments on commit 9e090ca

Please sign in to comment.