[tracker/clientapi-2: 3/4] libtracker-miner: Fixed evolution plugin enable/disable calling exit()
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/clientapi-2: 3/4] libtracker-miner: Fixed evolution plugin enable/disable calling exit()
- Date: Thu, 14 Jan 2010 12:30:39 +0000 (UTC)
commit 4ab19e46d10d373c19c41531869cc1ee4ea1dd78
Author: Martyn Russell <martyn lanedo com>
Date: Thu Jan 14 12:10:28 2010 +0000
libtracker-miner: Fixed evolution plugin enable/disable calling exit()
This occurred because we didn't release the name when we clean up the
dbus data for the miner. Subsequently, disabling and then enabling the
plugin would try to re-register the miner's name and find it was in
use and so exit() would be called in libtracker-miner. Now this
is fixed and Evolution doesn't completely exit.
src/libtracker-miner/tracker-miner.c | 73 +++++++++++++++++++++++++++-------
1 files changed, 58 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner.c b/src/libtracker-miner/tracker-miner.c
index be614e7..a045ea9 100644
--- a/src/libtracker-miner/tracker-miner.c
+++ b/src/libtracker-miner/tracker-miner.c
@@ -62,8 +62,9 @@ struct TrackerMinerPrivate {
};
typedef struct {
+ gchar *registered_name;
DBusGConnection *connection;
- DBusGProxy *gproxy;
+ DBusGProxy *proxy;
GHashTable *name_monitors;
} DBusData;
@@ -466,7 +467,7 @@ dbus_register_service (DBusGProxy *proxy,
const gchar *name)
{
GError *error = NULL;
- guint result;
+ guint result;
g_message ("Registering D-Bus service...\n"
" Name:'%s'",
@@ -476,7 +477,7 @@ dbus_register_service (DBusGProxy *proxy,
name,
DBUS_NAME_FLAG_DO_NOT_QUEUE,
&result, &error)) {
- g_critical ("Could not acquire name:'%s', %s",
+ g_critical ("Could not register name:'%s', %s",
name,
error ? error->message : "no error given");
g_error_free (error);
@@ -495,6 +496,45 @@ dbus_register_service (DBusGProxy *proxy,
}
static gboolean
+dbus_release_service (DBusGProxy *proxy,
+ const gchar *name)
+{
+ GError *error = NULL;
+ guint result;
+
+ g_message ("Releasing D-Bus service...\n"
+ " Name:'%s'",
+ name);
+
+ if (!org_freedesktop_DBus_release_name (proxy, name, &result, &error)) {
+ g_critical ("Could not release name:'%s', %s",
+ name,
+ error ? error->message : "no error given");
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ switch (result) {
+ case DBUS_RELEASE_NAME_REPLY_RELEASED:
+ break;
+
+ case DBUS_RELEASE_NAME_REPLY_NON_EXISTENT:
+ g_critical ("D-Bus service name:'%s' does not exist?",
+ name);
+ return FALSE;
+
+ case DBUS_RELEASE_NAME_REPLY_NOT_OWNER:
+ g_critical ("D-Bus service name:'%s' was not started by us, "
+ "we can not release the name!",
+ name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
dbus_register_object (GObject *object,
DBusGConnection *connection,
DBusGProxy *proxy,
@@ -579,8 +619,11 @@ dbus_data_destroy (gpointer data)
dd = data;
- if (dd->gproxy) {
- g_object_unref (dd->gproxy);
+ /* Release the service name for the miner */
+ dbus_release_service (dd->proxy, dd->registered_name);
+
+ if (dd->proxy) {
+ g_object_unref (dd->proxy);
}
if (dd->connection) {
@@ -600,7 +643,7 @@ dbus_data_new (TrackerMiner *miner,
{
DBusData *data;
DBusGConnection *connection;
- DBusGProxy *gproxy;
+ DBusGProxy *proxy;
GError *error = NULL;
gchar *full_name, *full_path;
@@ -613,7 +656,7 @@ dbus_data_new (TrackerMiner *miner,
return NULL;
}
- gproxy = dbus_g_proxy_new_for_name (connection,
+ proxy = dbus_g_proxy_new_for_name (connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
@@ -621,33 +664,33 @@ dbus_data_new (TrackerMiner *miner,
/* Register the service name for the miner */
full_name = g_strconcat (TRACKER_MINER_DBUS_NAME_PREFIX, name, NULL);
- if (!dbus_register_service (gproxy, full_name)) {
- g_object_unref (gproxy);
+ if (!dbus_register_service (proxy, full_name)) {
+ g_object_unref (proxy);
g_free (full_name);
return NULL;
}
- g_free (full_name);
-
full_path = g_strconcat (TRACKER_MINER_DBUS_PATH_PREFIX, name, NULL);
if (!dbus_register_object (G_OBJECT (miner),
- connection, gproxy,
+ connection, proxy,
&dbus_glib_tracker_miner_object_info,
full_path)) {
- g_object_unref (gproxy);
+ g_object_unref (proxy);
+ g_free (full_name);
g_free (full_path);
return NULL;
}
- dbus_set_name_monitor (miner, gproxy);
+ dbus_set_name_monitor (miner, proxy);
g_free (full_path);
/* Now we're successfully connected and registered, create the data */
data = g_slice_new0 (DBusData);
+ data->registered_name = full_name;
data->connection = dbus_g_connection_ref (connection);
- data->gproxy = g_object_ref (gproxy);
+ data->proxy = g_object_ref (proxy);
return data;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]