[Telepathy-commits] [telepathy-mission-control/master] Fix possible crash happening when interfaces are already ready
mardy
mardy at 64d1ce6a-1406-0410-9ac8-afed03b27183
Mon Nov 17 00:05:12 PST 2008
If _mc_iface_call_when_all_ready() was crashing if called when the interfaces
where already ready. So, keep a reference to the structure while the call is
being executed.
Rename a struct member for better readability.
git-svn-id: https://projects.maemo.org/svn/chavo/trunk/framework/open/telepathy-mission-control@20530 64d1ce6a-1406-0410-9ac8-afed03b27183
---
libmcclient/dbus-api.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libmcclient/dbus-api.c b/libmcclient/dbus-api.c
index 4e45d33..a14d9d8 100644
--- a/libmcclient/dbus-api.c
+++ b/libmcclient/dbus-api.c
@@ -249,7 +249,7 @@ typedef struct _MultiCbData {
gpointer user_data;
GDestroyNotify destroy;
gint remaining_ifaces;
- gint remaining_destroys;
+ gint ref_count;
GError *error;
} MultiCbData;
@@ -258,9 +258,9 @@ multi_cb_data_free (gpointer ptr)
{
MultiCbData *mcbd = ptr;
- mcbd->remaining_destroys--;
- g_assert (mcbd->remaining_destroys >= 0);
- if (mcbd->remaining_destroys == 0)
+ mcbd->ref_count--;
+ g_assert (mcbd->ref_count >= 0);
+ if (mcbd->ref_count == 0)
{
if (mcbd->destroy)
mcbd->destroy (mcbd->user_data);
@@ -303,16 +303,18 @@ _mc_iface_call_when_all_ready (TpProxy *proxy, GType type,
mcbd->callback = callback;
mcbd->user_data = user_data;
mcbd->destroy = destroy;
+ mcbd->ref_count = 1;
for (iface = va_arg (ifaces, GQuark); iface != 0;
iface = va_arg (ifaces, GQuark))
{
mcbd->remaining_ifaces++;
- mcbd->remaining_destroys++;
+ mcbd->ref_count++;
_mc_iface_call_when_ready (proxy, type, iface,
call_when_all_ready_cb,
mcbd, multi_cb_data_free, weak_object);
}
va_end (ifaces);
+ multi_cb_data_free (mcbd);
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list