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
1=== modified file 'softwarecenter/ui/gtk3/app.py'
2--- softwarecenter/ui/gtk3/app.py 2012-04-10 15:49:17 +0000
3+++ softwarecenter/ui/gtk3/app.py 2012-04-13 10:05:22 +0000
4@@ -131,6 +131,10 @@
5 dbus.service.Object.__init__(self, bus_name, object_path)
6 self.parent = parent
7
8+ def stop(self):
9+ """ stop the dbus controller and remove from the bus """
10+ self.remove_from_connection()
11+
12 @dbus.service.method('com.ubuntu.SoftwarecenterIFace')
13 def bringToFront(self, args):
14 if args != 'nothing-to-show':
15@@ -513,14 +517,32 @@
16 def on_review_stats_loaded(self, reviews):
17 LOG.debug("on_review_stats_loaded: '%s'" % len(reviews))
18
19- def on_window_main_delete_event(self, widget, event):
20+ def close_app(self):
21+ """ perform tasks like save-state etc when the application is
22+ exited
23+ """
24+ # this may happen during the early initialization
25+ # when "app.run()" was called but has not finished seting up the
26+ # stuff yet, in this case its ok to just exit
27+ if Gtk.main_level() == 0:
28+ LOG.info("closing before the regular main loop was run")
29+ sys.exit(0)
30+ # this is the case when it regularly runs
31 if hasattr(self, "glaunchpad"):
32 self.glaunchpad.shutdown()
33 self.save_state()
34+ # this will not throw exceptions in pygi but "only" log via g_critical
35+ # to the terminal but it might in the future so we add a handler here
36 try:
37 Gtk.main_quit()
38- except Exception as e:
39- LOG.warning(e)
40+ except:
41+ LOG.exception("Gtk.main_quit failed")
42+ # ensure that the dbus controller is really gone, just for good
43+ # measure
44+ self.dbusControler.stop()
45+ # exit here explictely to ensure that no further gtk event loops or
46+ # threads run and cause havoc on exit (LP: #914393)
47+ sys.exit(0)
48
49 def on_window_main_key_press_event(self, widget, event):
50 """ Define all the accelerator keys here - slightly messy, but the ones
51@@ -827,7 +849,10 @@
52 get_appmanager().request_action(app, [], [], AppActions.REMOVE)
53
54 def on_menuitem_close_activate(self, widget):
55- Gtk.main_quit()
56+ self.close_app()
57+
58+ def on_window_main_delete_event(self, widget, event):
59+ self.close_app()
60
61 # Edit Menu
62 def on_menu_edit_activate(self, menuitem):
63@@ -1171,11 +1196,15 @@
64 '/com/ubuntu/Softwarecenter')
65 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')
66 if args:
67- iface.bringToFront(args)
68+ res = iface.bringToFront(args)
69 else:
70 # None can not be transported over dbus
71- iface.bringToFront('nothing-to-show')
72- sys.exit()
73+ res = iface.bringToFront('nothing-to-show')
74+ # ensure that the running s-c is
75+ if res is not True:
76+ LOG.info("found a running software-center on dbus, "
77+ "reconnecting")
78+ sys.exit()
79 except dbus.DBusException:
80 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
81 self.dbusControler = SoftwarecenterDbusController(self, bus_name)

Subscribers

People subscribed via source and target branches