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

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

Description of the change

This branch fixes at least one incarnation of #772549. It also adds some cleanup around the dbus
controller to ensure that its really stopped and working properly. Most of it is probably not needed,
but given that annoying effects if it fails the extra measures are probably a good idea.

To test:
1. open software-center
2. close it via window-close-button really quickly
3. open software-center again in a new terminal
4. see that it shows a empty window

(4) is fixed with this branch.

To post a comment you must log in.
lp:~mvo/software-center/lp772549 updated
2973. By Michael Vogt

softwarecenter/ui/gtk3/app.py: move the Gtk.main_quit() before the dbusController.stop and add exception handler for good measure

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

Michael, this is great! Does the trick for me perfectly for the case of the early quit of USC.

This is a really annoying bug and it's great to have it fixed, thank you!!

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 09:02:19 +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,29 @@
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
46 def on_window_main_key_press_event(self, widget, event):
47 """ Define all the accelerator keys here - slightly messy, but the ones
48@@ -827,7 +846,10 @@
49 get_appmanager().request_action(app, [], [], AppActions.REMOVE)
50
51 def on_menuitem_close_activate(self, widget):
52- Gtk.main_quit()
53+ self.close_app()
54+
55+ def on_window_main_delete_event(self, widget, event):
56+ self.close_app()
57
58 # Edit Menu
59 def on_menu_edit_activate(self, menuitem):
60@@ -1171,11 +1193,15 @@
61 '/com/ubuntu/Softwarecenter')
62 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')
63 if args:
64- iface.bringToFront(args)
65+ res = iface.bringToFront(args)
66 else:
67 # None can not be transported over dbus
68- iface.bringToFront('nothing-to-show')
69- sys.exit()
70+ res = iface.bringToFront('nothing-to-show')
71+ # ensure that the running s-c is
72+ if res is not True:
73+ LOG.info("found a running software-center on dbus, "
74+ "reconnecting")
75+ sys.exit()
76 except dbus.DBusException:
77 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
78 self.dbusControler = SoftwarecenterDbusController(self, bus_name)

Subscribers

People subscribed via source and target branches