Skip to content

Commit

Permalink
Debugger: Refactor widget packing
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 geany#1014.
  • Loading branch information
eht16 committed Oct 19, 2020
1 parent 6bdbef5 commit 51b0d92
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions debugger/src/tpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,20 @@ void tpage_pack_widgets(gboolean tabbed)
{
/* root box */
GtkWidget *root = NULL, *oldroot = NULL;
GtkWidget **widget = NULL;
GList *children = gtk_container_get_children(GTK_CONTAINER(tab_target));
if (children)
{
int i = 0;

GtkWidget **widget_ref = NULL;
oldroot = (GtkWidget*)children->data;

/* unparent widgets */
do
for (int i = 0; widgets[i]; i++)
{
widget = widgets[i];
g_object_ref(widget);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(*widget)), *widget);
i++;
} while (widget);
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 @@ -266,13 +264,10 @@ void tpage_pack_widgets(gboolean tabbed)

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

Expand Down

0 comments on commit 51b0d92

Please sign in to comment.