sizerequest: Remove for_size parameter from push_recursion_check

It's not needed anymore after also fixing the warning message to not
mention the old get_preferred* functions.
This commit is contained in:
Timm Bäder 2017-05-18 09:43:32 +02:00 committed by Matthias Clasen
parent b0c7a876a9
commit 4d7768d5e8

View File

@ -39,38 +39,25 @@ static GQuark recursion_check_quark = 0;
static void static void
push_recursion_check (GtkWidget *widget, push_recursion_check (GtkWidget *widget,
GtkOrientation orientation, GtkOrientation orientation)
gint for_size)
{ {
const char *previous_method; gboolean in_measure = FALSE;
const char *method;
if (recursion_check_quark == 0) if (recursion_check_quark == 0)
recursion_check_quark = g_quark_from_static_string ("gtk-size-request-in-progress"); recursion_check_quark = g_quark_from_static_string ("gtk-size-request-in-progress");
previous_method = g_object_get_qdata (G_OBJECT (widget), recursion_check_quark); in_measure = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), recursion_check_quark));
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (in_measure)
{ {
method = for_size < 0 ? "get_width" : "get_width_for_height"; g_warning ("%s %p: widget tried to gtk_widget_measure inside "
} " GtkWidget::measure implementation. "
else "Should just invoke GTK_WIDGET_GET_CLASS(widget)->measure "
{ "directly rather than using gtk_widget_measure",
method = for_size < 0 ? "get_height" : "get_height_for_width"; G_OBJECT_TYPE_NAME (widget), widget);
} }
if (previous_method != NULL) g_object_set_qdata (G_OBJECT (widget), recursion_check_quark, GINT_TO_POINTER(TRUE));
{
g_warning ("%s %p: widget tried to gtk_widget_%s inside "
" GtkWidget ::%s implementation. "
"Should just invoke GTK_WIDGET_GET_CLASS(widget)->%s "
"directly rather than using gtk_widget_%s",
G_OBJECT_TYPE_NAME (widget), widget,
method, previous_method,
method, method);
}
g_object_set_qdata (G_OBJECT (widget), recursion_check_quark, (char*) method);
} }
static void static void
@ -80,7 +67,7 @@ pop_recursion_check (GtkWidget *widget,
g_object_set_qdata (G_OBJECT (widget), recursion_check_quark, NULL); g_object_set_qdata (G_OBJECT (widget), recursion_check_quark, NULL);
} }
#else #else
#define push_recursion_check(widget, orientation, for_size) #define push_recursion_check(widget, orientation)
#define pop_recursion_check(widget, orientation) #define pop_recursion_check(widget, orientation)
#endif /* G_ENABLE_CONSISTENCY_CHECKS */ #endif /* G_ENABLE_CONSISTENCY_CHECKS */
@ -167,7 +154,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
{ {
if (for_size < 0) if (for_size < 0)
{ {
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation);
widget_class->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1, widget_class->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
&min_size, &nat_size, NULL, NULL); &min_size, &nat_size, NULL, NULL);
pop_recursion_check (widget, orientation); pop_recursion_check (widget, orientation);
@ -191,7 +178,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
&dummy, &dummy,
&adjusted_for_size); &adjusted_for_size);
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation);
widget_class->measure (widget, widget_class->measure (widget,
GTK_ORIENTATION_HORIZONTAL, GTK_ORIENTATION_HORIZONTAL,
MAX (adjusted_for_size, minimum_height), MAX (adjusted_for_size, minimum_height),
@ -204,7 +191,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
{ {
if (for_size < 0) if (for_size < 0)
{ {
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation);
widget_class->measure (widget, widget_class->measure (widget,
GTK_ORIENTATION_VERTICAL, GTK_ORIENTATION_VERTICAL,
-1, -1,
@ -231,7 +218,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
&dummy, &dummy,
&adjusted_for_size); &adjusted_for_size);
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation);
widget_class->measure (widget, widget_class->measure (widget,
GTK_ORIENTATION_VERTICAL, GTK_ORIENTATION_VERTICAL,
MAX (adjusted_for_size, minimum_width), MAX (adjusted_for_size, minimum_width),