[gtk/mcatanzaro/unparent-warning] Add warning when widget with no parent is unparented
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/mcatanzaro/unparent-warning] Add warning when widget with no parent is unparented
- Date: Thu, 7 Jan 2021 15:47:04 +0000 (UTC)
commit 9fa6d9b1f4b27293a3ba37141f0e1ab313838588
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Jan 7 09:45:43 2021 -0600
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.
gtk/gtkwidget.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 239f7735e8..8cfd5e56f4 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]