1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-17 16:05:36 +00:00

calls-dummy-origin: Fix ordering of state change and call removal callbacks

This commit is contained in:
Bob Ham 2019-07-22 11:52:44 +01:00
parent f12b411813
commit ebf579af78
2 changed files with 40 additions and 3 deletions

View file

@ -108,12 +108,32 @@ remove_calls (CallsDummyOrigin *self, const gchar *reason)
} }
struct DisconnectedData
{
CallsDummyOrigin *self;
CallsCall *call;
};
static gboolean
disconnected_cb (struct DisconnectedData *data)
{
remove_call (data->self, data->call, "Disconnected");
g_object_unref (G_OBJECT (data->call));
g_object_unref (G_OBJECT (data->self));
g_free (data);
return FALSE;
}
static void static void
call_state_changed_cb (CallsDummyOrigin *self, call_state_changed_cb (CallsDummyOrigin *self,
CallsCallState new_state, CallsCallState new_state,
CallsCallState old_state, CallsCallState old_state,
CallsCall *call) CallsCall *call)
{ {
struct DisconnectedData *data;
if (new_state != CALLS_CALL_STATE_DISCONNECTED) if (new_state != CALLS_CALL_STATE_DISCONNECTED)
{ {
return; return;
@ -122,7 +142,16 @@ call_state_changed_cb (CallsDummyOrigin *self,
g_return_if_fail (CALLS_IS_DUMMY_ORIGIN (self)); g_return_if_fail (CALLS_IS_DUMMY_ORIGIN (self));
g_return_if_fail (CALLS_IS_CALL (call)); g_return_if_fail (CALLS_IS_CALL (call));
remove_call (self, call, "Disconnected"); // We add an idle callback so that all of the state change handlers
// are dealt with before the removal
data = g_new (struct DisconnectedData, 1);
data->self = self;
data->call = call;
g_object_ref (G_OBJECT (self));
g_object_ref (G_OBJECT (call));
g_idle_add ((GSourceFunc)disconnected_cb, data);
} }

View file

@ -43,14 +43,22 @@ test_dummy_call_get_state (CallFixture *fixture,
} }
static gboolean
test_dummy_call_hang_up_idle_cb (CallsDummyOrigin *origin)
{
g_assert_null (calls_origin_get_calls (CALLS_ORIGIN (origin)));
return FALSE;
}
static void static void
test_dummy_call_hang_up (CallFixture *fixture, test_dummy_call_hang_up (CallFixture *fixture,
gconstpointer user_data) gconstpointer user_data)
{ {
calls_call_hang_up (CALLS_CALL (fixture->dummy_call)); calls_call_hang_up (CALLS_CALL (fixture->dummy_call));
g_assert_null (calls_origin_get_calls // Mirror the dummy origin's use of an idle callback
(CALLS_ORIGIN (fixture->parent.dummy_origin))); g_idle_add ((GSourceFunc)test_dummy_call_hang_up_idle_cb,
fixture->parent.dummy_origin);
} }
gint gint