diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 994ee7b377..1ef826b108 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -312,6 +312,7 @@ static void gtk_scrolled_window_get_property (GObject *objec guint prop_id, GValue *value, GParamSpec *pspec); +static void gtk_scrolled_window_finalize (GObject *object); static void gtk_scrolled_window_destroy (GtkWidget *widget); static gboolean gtk_scrolled_window_draw (GtkWidget *widget, @@ -519,6 +520,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) gobject_class->set_property = gtk_scrolled_window_set_property; gobject_class->get_property = gtk_scrolled_window_get_property; + gobject_class->finalize = gtk_scrolled_window_finalize; widget_class->destroy = gtk_scrolled_window_destroy; widget_class->draw = gtk_scrolled_window_draw; @@ -1792,7 +1794,8 @@ gtk_scrolled_window_measure (GtkCssGadget *gadget, natural_req.width += priv->min_content_width; extra_width = -1; } - else if (policy_may_be_visible (priv->vscrollbar_policy) && !priv->use_indicators) + + if (policy_may_be_visible (priv->vscrollbar_policy) && !priv->use_indicators) { minimum_req.width += vscrollbar_requisition.width; natural_req.width += vscrollbar_requisition.width; @@ -1832,7 +1835,8 @@ gtk_scrolled_window_measure (GtkCssGadget *gadget, natural_req.height += priv->min_content_height; extra_height = -1; } - else if (policy_may_be_visible (priv->hscrollbar_policy) && !priv->use_indicators) + + if (policy_may_be_visible (priv->hscrollbar_policy) && !priv->use_indicators) { minimum_req.height += hscrollbar_requisition.height; natural_req.height += hscrollbar_requisition.height; @@ -2776,13 +2780,22 @@ gtk_scrolled_window_destroy (GtkWidget *widget) priv->scroll_events_overshoot_id = 0; } + GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->destroy (widget); +} + +static void +gtk_scrolled_window_finalize (GObject *object) +{ + GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object); + GtkScrolledWindowPrivate *priv = scrolled_window->priv; + g_clear_object (&priv->drag_gesture); g_clear_object (&priv->swipe_gesture); g_clear_object (&priv->long_press_gesture); g_clear_object (&priv->gadget); g_clear_pointer (&priv->scroll_history, (GDestroyNotify) g_array_unref); - GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->destroy (widget); + G_OBJECT_CLASS (gtk_scrolled_window_parent_class)->finalize (object); } static void