From 49c57c4a6ffd6d777a61f3c4b055d3ba91edec54 Mon Sep 17 00:00:00 2001 From: James Westman Date: Tue, 21 Feb 2023 17:21:28 -0600 Subject: [PATCH] visualizer-group: Fix insert() sysprof_visualizer_group_insert() would insert widgets intended for position 0 at position 1 instead. This caused a bug in the marks section where the "Timings" row, which is supposed to be at the top, would instead be at position 1. Because the menu buttons are in the top row, disabling a row through the menu could cause the menu buttons to disappear. --- src/libsysprof-ui/sysprof-visualizer-group.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libsysprof-ui/sysprof-visualizer-group.c b/src/libsysprof-ui/sysprof-visualizer-group.c index fe789d1d..2053e036 100644 --- a/src/libsysprof-ui/sysprof-visualizer-group.c +++ b/src/libsysprof-ui/sysprof-visualizer-group.c @@ -392,11 +392,14 @@ sysprof_visualizer_group_insert (SysprofVisualizerGroup *self, g_return_if_fail (SYSPROF_IS_VISUALIZER_GROUP (self)); g_return_if_fail (SYSPROF_IS_VISUALIZER (visualizer)); - sibling = gtk_widget_get_first_child (GTK_WIDGET (priv->visualizers)); - while (position > 1 && sibling) + if (position > 0) { - sibling = gtk_widget_get_next_sibling (sibling); - position--; + sibling = gtk_widget_get_first_child (GTK_WIDGET (priv->visualizers)); + while (position > 1 && sibling) + { + sibling = gtk_widget_get_next_sibling (sibling); + position--; + } } gtk_box_insert_child_after (priv->visualizers, GTK_WIDGET (visualizer), sibling);