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
=== 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 09:02:19 +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,29 @@
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()
524543
525 def on_window_main_key_press_event(self, widget, event):544 def on_window_main_key_press_event(self, widget, event):
526 """ Define all the accelerator keys here - slightly messy, but the ones545 """ Define all the accelerator keys here - slightly messy, but the ones
@@ -827,7 +846,10 @@
827 get_appmanager().request_action(app, [], [], AppActions.REMOVE)846 get_appmanager().request_action(app, [], [], AppActions.REMOVE)
828847
829 def on_menuitem_close_activate(self, widget):848 def on_menuitem_close_activate(self, widget):
830 Gtk.main_quit()849 self.close_app()
850
851 def on_window_main_delete_event(self, widget, event):
852 self.close_app()
831853
832# Edit Menu854# Edit Menu
833 def on_menu_edit_activate(self, menuitem):855 def on_menu_edit_activate(self, menuitem):
@@ -1171,11 +1193,15 @@
1171 '/com/ubuntu/Softwarecenter')1193 '/com/ubuntu/Softwarecenter')
1172 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')1194 iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')
1173 if args:1195 if args:
1174 iface.bringToFront(args)1196 res = iface.bringToFront(args)
1175 else:1197 else:
1176 # None can not be transported over dbus1198 # None can not be transported over dbus
1177 iface.bringToFront('nothing-to-show')1199 res = iface.bringToFront('nothing-to-show')
1178 sys.exit()1200 # ensure that the running s-c is
1201 if res is not True:
1202 LOG.info("found a running software-center on dbus, "
1203 "reconnecting")
1204 sys.exit()
1179 except dbus.DBusException:1205 except dbus.DBusException:
1180 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)1206 bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
1181 self.dbusControler = SoftwarecenterDbusController(self, bus_name)1207 self.dbusControler = SoftwarecenterDbusController(self, bus_name)

Subscribers

People subscribed via source and target branches