[gtk/ebassi/childless-stack-page] stack: Assert that StackPage:child is set
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ebassi/childless-stack-page] stack: Assert that StackPage:child is set
- Date: Mon, 29 Nov 2021 17:28:08 +0000 (UTC)
commit cc27448f95717d11161be55574f8108f35f95202
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Nov 29 16:57:21 2021 +0000
stack: Assert that StackPage:child is set
Childless GtkStackPage instances are not allowed, otherwise everything
falls apart in random places.
gtk/gtkstack.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index facf7ca3eb..360ee56776 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -395,6 +395,20 @@ gtk_stack_page_set_property (GObject *object,
break;
}
}
+
+static void
+gtk_stack_page_constructed (GObject *gobject)
+{
+ GtkStackPage *self = GTK_STACK_PAGE (gobject);
+
+ if (G_UNLIKELY (self->widget == NULL))
+ g_error ("GtkStackPage '%s' [%p] is missing a child widget",
+ self->name != NULL ? self->name : "<unnamed>",
+ self);
+
+ G_OBJECT_CLASS (gtk_stack_page_parent_class)->constructed (gobject);
+}
+
static void
gtk_stack_page_class_init (GtkStackPageClass *class)
{
@@ -404,6 +418,7 @@ gtk_stack_page_class_init (GtkStackPageClass *class)
object_class->dispose = gtk_stack_page_dispose;
object_class->get_property = gtk_stack_page_get_property;
object_class->set_property = gtk_stack_page_set_property;
+ object_class->constructed = gtk_stack_page_constructed;
/**
* GtkStackPage:child: (attributes org.gtk.Property.get=gtk_stack_page_get_child)
@@ -2583,7 +2598,7 @@ gtk_stack_measure (GtkWidget *widget,
int min_for_size;
gtk_widget_measure (child, OPPOSITE_ORIENTATION (orientation), -1, &min_for_size, NULL, NULL,
NULL);
-
+
gtk_widget_measure (child, orientation, MAX (min_for_size, for_size), &child_min, &child_nat,
NULL, NULL);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]