views/week-grid: Only set parent when child_data->widget has been created

`add_event_to_block()` assumes that the child widget has never been
parented, so it will always set the parent widget when the widget
is already parented, which triggers a critical error in GTK.

This patch addresses this situation by only parenting when the
widget has just been created. Additionally, it asserts that the
parent widget is `self` in the end, so that it crashes if this
is incorrect.

Fixes: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/1643>
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/863>
This commit is contained in:
Hari Rana
2026-10-03 19:24:19 -04:00
parent 81fa0f29c4
commit b1f6e609c6
+3 -1
View File
@@ -254,9 +254,11 @@ add_event_to_block (GcalWeekGrid *self,
NULL);
g_signal_connect (child_data->widget, "activate", G_CALLBACK (on_event_widget_activated_cb), self);
gtk_widget_set_parent (child_data->widget, GTK_WIDGET (self));
}
gtk_widget_set_parent (child_data->widget, GTK_WIDGET (self));
g_assert (gtk_widget_get_parent (child_data->widget) == GTK_WIDGET (self));
}
static void