Add warning when widget with no parent is unparented

This is a little controversial -- Benjamin is not fond of adding new
warnings in GTK 4 -- but it is not really an API break, and will help
developers avoid adding unnecessary code to unparent widgets that are
already unparented elsewhere. Also, it's still quite early in the life
of GTK 4, before most apps have been ported. The earlier we add this
warning, the better.
This commit is contained in:
Michael Catanzaro
2021-01-07 09:45:43 -06:00
parent e930a20522
commit db059847b2

View File

@@ -2497,7 +2497,11 @@ gtk_widget_unparent (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
if (priv->parent == NULL)
return;
{
g_warning ("Attempted to unparent %s %p, but it already has no parent.",
G_OBJECT_TYPE_NAME (widget), widget);
return;
}
gtk_widget_push_verify_invariants (widget);