[geany/geany-plugins] 6c1bf5: Debugger: Refactor widget packing (#1017)
Enrico Tröger
git-noreply at xxxxx
Sat Oct 24 10:11:37 UTC 2020
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: GitHub <noreply at github.com>
Date: Sat, 24 Oct 2020 10:11:37 UTC
Commit: 6c1bf58c4f153611bbea9f824b443f35eb0079ed
https://github.com/geany/geany-plugins/commit/6c1bf58c4f153611bbea9f824b443f35eb0079ed
Log Message:
-----------
Debugger: Refactor widget packing (#1017)
This fixes a cppcheck 2.2+ confusion about uninitialized widgets array
and also makes the code a bit more readable.
Closes #1014.
Modified Paths:
--------------
debugger/src/tpage.c
Modified: debugger/src/tpage.c
19 lines changed, 7 insertions(+), 12 deletions(-)
===================================================================
@@ -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);
}
@@ -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);
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list