[libhandy] css: Don't assume parent class == GtkBinClass



commit 8612ab3aba50d8444a9db4ae9a348e3f814859d3
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat Mar 6 15:48:14 2021 +0500

    css: Don't assume parent class == GtkBinClass
    
    This is true for direct GtkBin subclasses, but not for their subclasses.
    
    Now, while HdyClamp is final and it's safe to assume this,
    HdyPreferencesGroup is derivable and all its subclasses crash.

 src/hdy-css.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/hdy-css.c b/src/hdy-css.c
index fc336060..dcff86ea 100644
--- a/src/hdy-css.c
+++ b/src/hdy-css.c
@@ -186,9 +186,9 @@ hdy_css_get_preferred_width (GtkWidget *widget,
                              gint      *minimum,
                              gint      *natural)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
+  GObjectClass *pclass = g_type_class_peek (GTK_TYPE_BIN);
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   GTK_WIDGET_CLASS (pclass)->get_preferred_width (widget, minimum, natural);
 
@@ -201,9 +201,9 @@ hdy_css_get_preferred_width_for_height (GtkWidget *widget,
                                         gint      *minimum,
                                         gint      *natural)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
+  GObjectClass *pclass = g_type_class_peek (GTK_TYPE_BIN);
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   GTK_WIDGET_CLASS (pclass)->get_preferred_width_for_height (widget, height, minimum, natural);
 
@@ -215,9 +215,9 @@ hdy_css_get_preferred_height (GtkWidget *widget,
                               gint      *minimum,
                               gint      *natural)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
+  GObjectClass *pclass = g_type_class_peek (GTK_TYPE_BIN);
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   GTK_WIDGET_CLASS (pclass)->get_preferred_height (widget, minimum, natural);
 
@@ -230,9 +230,9 @@ hdy_css_get_preferred_height_for_width (GtkWidget *widget,
                                         gint      *minimum,
                                         gint      *natural)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
+  GObjectClass *pclass = g_type_class_peek (GTK_TYPE_BIN);
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   GTK_WIDGET_CLASS (pclass)->get_preferred_height_for_width (widget, width, minimum, natural);
 
@@ -243,10 +243,9 @@ void
 hdy_css_size_allocate_bin (GtkWidget     *widget,
                            GtkAllocation *allocation)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
   GtkAllocation child_alloc;
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   hdy_css_size_allocate_self (widget, allocation);
   gtk_widget_set_allocation (widget, allocation);
@@ -260,9 +259,9 @@ gboolean
 hdy_css_draw_bin (GtkWidget *widget,
                   cairo_t   *cr)
 {
-  GObjectClass *pclass = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget));
+  GObjectClass *pclass = g_type_class_peek (GTK_TYPE_BIN);
 
-  g_assert (G_OBJECT_CLASS_TYPE (pclass) == GTK_TYPE_BIN);
+  g_assert (GTK_IS_BIN (widget));
 
   hdy_css_draw (widget, cr);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]