Skip to content

Commit

Permalink
Debugger: Refactor widget packing (#1017)
Browse files Browse the repository at this point in the history
This fixes a cppcheck 2.2+ confusion about uninitialized widgets array
and also makes the code a bit more readable.
Closes #1014.
  • Loading branch information
eht16 committed Oct 24, 2020
1 parent 0882894 commit 6c1bf58
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions debugger/src/tpage.c
Expand Up @@ -142,19 +142,16 @@ void tpage_pack_widgets(gboolean tabbed)
GList *children = gtk_container_get_children(GTK_CONTAINER(tab_target));
if (children)
{
int i;

oldroot = (GtkWidget*)children->data;

/* unparent widgets */
i = 0;
while (widgets[i])
for (int i = 0; widgets[i]; i++)
{
g_object_ref(*widgets[i]);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(*widgets[i])), *widgets[i]);
i++;
GtkWidget **widget_ref = widgets[i];
g_object_ref(*widget_ref);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(*widget_ref)), *widget_ref);
}

g_list_free(children);
}

Expand Down Expand Up @@ -265,11 +262,9 @@ void tpage_pack_widgets(gboolean tabbed)

if (oldroot)
{
int i = 0;
while (widgets[i])
for (int i = 0; widgets[i]; i++)
{
g_object_unref(*widgets[i]);
i++;
}
gtk_container_remove(GTK_CONTAINER(tab_target), oldroot);
}
Expand Down

0 comments on commit 6c1bf58

Please sign in to comment.