Merge lp:~mvo/software-center/lp914393 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2971
Proposed branch: lp:~mvo/software-center/lp914393
Merge into: lp:software-center
Diff against target: 81 lines (+36/-7)
1 file modified
softwarecenter/ui/gtk3/app.py (+36/-7)
To merge this branch: bzr merge lp:~mvo/software-center/lp914393
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+101884@code.launchpad.net

Description of the change

Based on lp:~mvo/software-center/lp772549 this branch adds a explicit sys.exit() to ensure all
gtk event processing stops. This works around the issue in bug #914393 where it appears that:

softwarecenter.ui.gtk3.view.appdetailsview.AppDetailsView calls
 self.icon.set_from_pixbuf(pb) (in line 1379
even though the icon is already destroyed in the gtk/C world but not in the pygi/python world.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Please note that the root of this crash is hopefully addressed with my patch for gtk+ in
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/938090/comments/11
but even with that we should still merge this branch to avoid getting hit by similar problems
(and because AFAICT there is no reason to exit right away).

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thank you Michael, this seems a good and very reasonable approach to fix this issue, and it will be great when we get your fix for the root problem into gtk+. Thanks! Approved and will merge now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/app.py'
--- softwarecenter/ui/gtk3/app.py 2012-04-10 15:49:17 +0000
+++ softwarecenter/ui/gtk3/app.py 2012-04-13 10:05:22 +0000
@@ -131,6 +131,10 @@
131 dbus.service.Object.__init__(self, bus_name, object_path)131 dbus.service.Object.__init__(self, bus_name, object_path)
132 self.parent = parent132 self.parent = parent
133133
134 def stop(self):
135 """ stop the dbus controller and remove from the bus """
136 self.remove_from_connection()
137
134 @dbus.service.method('com.ubuntu.SoftwarecenterIFace')138 @dbus.service.method('com.ubuntu.SoftwarecenterIFace')
135 def bringToFront(self, args):139 def bringToFront(self, args):
136 if args != 'nothing-to-show':140 if args != 'nothing-to-show':
@@ -513,14 +517,32 @@
513 def on_review_stats_loaded(self, reviews):517 def on_review_stats_loaded(self, reviews):
514 LOG.debug("on_review_stats_loaded: '%s'" % len(reviews))518 LOG.debug("on_review_stats_loaded: '%s'" % len(reviews))
515519
516 def on_window_main_delete_event(self, widget, event):520 def close_app(self):
521 """ perform tasks like save-state etc when the application is
522 exited
523 """
524 # this may happen during the early initialization
525 # when "app.run()" was called but has not finished seting up the
526 # stuff yet, in this case its ok to just exit
527 if Gtk.main_level() == 0:
528 LOG.info("closing before the regular main loop was run")
529 sys.exit(0)
530 # this is the case when it regularly runs
517 if hasattr(self, "glaunchpad"):531 if hasattr(self, "glaunchpad"):
518 self.glaunchpad.shutdown()532 self.glaunchpad.shutdown()
519 self.save_state()533 self.save_state()
534 # this will not throw exceptions in pygi but "only" log via g_critical
535 # to the terminal but it might in the future so we add a handler here
520 try:536 try:
521 Gtk.main_quit()537 Gtk.main_quit()
522 except Exception as e:538 except:
523 LOG.warning(e)539 LOG.exception("Gtk.main_quit failed")
540 # ensure that the dbus controller is really gone, just for good
541 # measure
542 self.dbusControler.stop()
543 # exit here explictely to ensure that no further gtk event loops or
544 # threads run and cause havoc on exit (LP: #914393)
545 sys.exit(0)
524546
525 def on_window_main_key_press_event(self, widget, event):547 def on_window_main_key_press_event(self, widget, event):
526 """ Define all the accelerator keys here - slightly messy, but the ones548 """ Define all the accelerator keys here - slightly messy, but the ones
@@ -827,7 +849,10 @@
827 get_appmanager().request_action(app, [], [], AppActions.REMOVE)849 get_appmanager().request_action(app, [], [], AppActions.REMOVE)
828850
829 def on_menuitem_close_activate(self, widget):851 def on_menuitem_close_activate(self, widget):
830 Gtk.main_quit()852 self.close_app()
853
854 def on_window_main_delete_event(self, widget, event):
855 self.close_app()
831856
832# Edit Menu857# Edit Menu
833 def on_menu_edit_activate(self, menuitem):858 def on_menu_edit_activate(self, menuitem):
@@ -1171,11 +1196,15 @@
1171 '/com/ubuntu/Softwarecenter')1196 '/com/ubuntu/Softwarecenter')
1172 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')1197 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')
1173 if args:1198 if args:
1174 iface.bringToFront(args)1199 res = iface.bringToFront(args)
1175 else:1200 else:
1176 # None can not be transported over dbus1201 # None can not be transported over dbus
1177 iface.bringToFront('nothing-to-show')1202 res = iface.bringToFront('nothing-to-show')
1178 sys.exit()1203 # ensure that the running s-c is
1204 if res is not True:
1205 LOG.info("found a running software-center on dbus, "
1206 "reconnecting")
1207 sys.exit()
1179 except dbus.DBusException:1208 except dbus.DBusException:
1180 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)1209 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
1181 self.dbusControler = SoftwarecenterDbusController(self, bus_name)1210 self.dbusControler = SoftwarecenterDbusController(self, bus_name)

Subscribers

People subscribed via source and target branches