[gtk+/wip/otte/queue-resize: 22/31] 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: 22/31] widget: Warn if size-unqueried widgets get allocated
- Date: Tue, 29 Sep 2015 21:23:37 +0000 (UTC)
commit f52b57b9c89bb70763167ac94f5c8dbf957d7a11
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 08fd24b..896d6c4 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 4229f1e..a3b463d 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]