[gtk+/wip/otte/queue-resize: 20/32] widget: Warn if size-unqueried widgets get allocated
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/queue-resize: 20/32] widget: Warn if size-unqueried widgets get allocated
- Date: Fri, 9 Oct 2015 13:35:50 +0000 (UTC)
commit c4eead047df5ac19da9b1081559708ca16a90cdc
Author: Benjamin Otte <otte redhat com>
Date: Mon Sep 28 05:21:06 2015 +0200
widget: Warn if size-unqueried widgets get allocated
Widgets should have gtk_widget_get_preferred_width/height() called
on them before gtk_widget_size_allocate() gets called.
Add a check for this.
gtk/gtkwidget.c | 7 +++++++
gtk/gtkwidgetprivate.h | 6 ++++++
2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 5c82bca..3d0a5fd 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5842,6 +5842,13 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG
+ if (gtk_widget_get_resize_needed (widget))
+ {
+ g_warning ("Allocating size to %s %p without calling gtk_widget_get_preferred_width/height(). "
+ "How does the code know the size to allocate?",
+ gtk_widget_get_name (widget), widget);
+ }
+
if (GTK_DEBUG_CHECK (GEOMETRY))
{
gint depth;
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 2e02308..566a562 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -288,6 +288,12 @@ gboolean gtk_widget_has_size_request (GtkWidget *widget);
/* inline getters */
+static inline gboolean
+gtk_widget_get_resize_needed (GtkWidget *widget)
+{
+ return widget->priv->resize_needed;
+}
+
static inline GtkWidget *
_gtk_widget_get_parent (GtkWidget *widget)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]