1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-28 14:49:30 +00:00

call-window: Improve readability of remove_call function

The casual reader might be tricked into believing CallsCallSelectorItem would
leak here, which was not actually the case.

(cherry picked from commit 2fc5533e1a)
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-10-28 14:58:34 +02:00
parent 90b105f45d
commit 9a7a11c82c

View file

@ -182,29 +182,23 @@ remove_call (CallsCallWindow *self,
CallsCall *call,
const gchar *reason)
{
g_autoptr (CallsCallSelectorItem) item = NULL;
gint position;
guint n_calls;
g_return_if_fail (CALLS_IS_CALL_WINDOW (self));
g_return_if_fail (CALLS_IS_CALL (call));
position = 0;
item = g_list_model_get_item (G_LIST_MODEL (self->calls), position);
while (item != NULL) {
n_calls = g_list_model_get_n_items (G_LIST_MODEL (self->calls));
for (guint i = 0; i < n_calls; i++) {
g_autoptr (CallsCallSelectorItem) item =
g_list_model_get_item (G_LIST_MODEL (self->calls), i);
CallsCallDisplay *display = calls_call_selector_item_get_display (item);
if (calls_call_display_get_call (display) == call) {
g_list_store_remove (self->calls, position);
g_list_store_remove (self->calls, i);
gtk_container_remove (GTK_CONTAINER (self->call_stack),
GTK_WIDGET (display));
break;
}
g_object_unref (item);
position++;
item = g_list_model_get_item (G_LIST_MODEL (self->calls), position);
}
update_visibility (self);