Cleanup browser model service on destroy.

Remove the activity service even if the owner is gone.
This commit is contained in:
Marco Pesenti Gritti 2006-09-12 13:21:18 +02:00
parent d65e8b88e7
commit 53f7cc1f34
4 changed files with 17 additions and 9 deletions

View File

@ -25,6 +25,7 @@ class BrowserActivity(Activity):
self._model = None
self.set_title("Web Page")
self.connect('destroy', self._destroy_cb)
vbox = gtk.VBox()
@ -123,3 +124,7 @@ class BrowserActivity(Activity):
self._notif_bar.set_action('goto_shared_location', 'Go There')
self._notif_bar.set_icon('stock_right')
self._notif_bar.show()
def _destroy_cb(self, window):
if self._model:
self._model.shutdown()

View File

@ -536,6 +536,9 @@ class PresenceService(object):
if not service:
return False
self._dbus_helper.ServiceDisappeared(service.object_path())
self._handle_remove_activity_service(service)
# Decompose service name if we can
(actid, buddy_name) = Service.decompose_service_name(full_name)
@ -545,10 +548,8 @@ class PresenceService(object):
except KeyError:
pass
else:
buddy.remove_service(service)
self._dbus_helper.ServiceDisappeared(service.object_path())
self._handle_remove_activity_service(service)
if not buddy.is_valid():
buddy.remove_service(service)
self._dbus_helper.BuddyDisappeared(buddy.object_path())
del self._buddies[buddy_name]
key = (service.get_full_name(), service.get_type())

View File

@ -68,8 +68,7 @@ class MeshGroup(goocanvas.Group):
self._activities[item.get_id()] = item
def _activity_disappeared_cb(self, activity):
print 'remove'
def _activity_disappeared_cb(self, pservice, activity):
if self._activities.has_key(activity.get_id()):
self.remove_child(self._activities[activity.get_id()])
del self._activities[activity.get_id()]

View File

@ -37,9 +37,9 @@ class LocalModel(AbstractModel):
self._notifier.notify(key)
def _setup_service(self):
service = self._pservice.share_activity(self._activity,
stype = LocalModel.SERVICE_TYPE)
self._setup_server(service)
self._service = self._pservice.share_activity(
self._activity, stype = LocalModel.SERVICE_TYPE)
self._setup_server(self._service)
# FIXME this is duplicated with StreamReader
def _setup_server(self, service):
@ -47,3 +47,6 @@ class LocalModel(AbstractModel):
logging.debug('Start model server on port %d' % (port))
p2p_server = network.GlibXMLRPCServer(("", port))
p2p_server.register_instance(ModelRequestHandler(self))
def shutdown(self):
self._pservice.unregister_service(self._service)