1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-08 04:45:31 +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.
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-10-28 14:58:34 +02:00
parent d7d97e8f67
commit 2fc5533e1a

View file

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