[libadwaita/wip/exalm/shader-crash: 1/3] indicator-bin: Free the shader in unrealize() instead of dispose()




commit a497ec3a2e3e8b0c664d27cbbc1de164d33ca22c
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Jul 20 13:18:54 2021 +0500

    indicator-bin: Free the shader in unrealize() instead of dispose()
    
    We need to do it while the renderer is still available as it needs to
    release the GL resources, so dispose() is too late.
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/234

 src/adw-indicator-bin.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-indicator-bin.c b/src/adw-indicator-bin.c
index 366be27c..b32aaba1 100644
--- a/src/adw-indicator-bin.c
+++ b/src/adw-indicator-bin.c
@@ -192,6 +192,16 @@ adw_indicator_bin_snapshot (GtkWidget   *widget,
   gtk_widget_snapshot_child (widget, self->indicator, snapshot);
 }
 
+static void
+adw_indicator_bin_unrealize (GtkWidget *widget)
+{
+  AdwIndicatorBin *self = ADW_INDICATOR_BIN (widget);
+
+  GTK_WIDGET_CLASS (adw_indicator_bin_parent_class)->unrealize (widget);
+
+  g_clear_object (&self->shader);
+}
+
 static void
 adw_indicator_bin_get_property (GObject    *object,
                                 guint       prop_id,
@@ -249,7 +259,6 @@ adw_indicator_bin_dispose (GObject *object)
 {
   AdwIndicatorBin *self = ADW_INDICATOR_BIN (object);
 
-  g_clear_object (&self->shader);
   g_clear_pointer (&self->child, gtk_widget_unparent);
   g_clear_pointer (&self->mask, gtk_widget_unparent);
   g_clear_pointer (&self->indicator, gtk_widget_unparent);
@@ -270,6 +279,7 @@ adw_indicator_bin_class_init (AdwIndicatorBinClass *klass)
   widget_class->measure = adw_indicator_bin_measure;
   widget_class->size_allocate = adw_indicator_bin_size_allocate;
   widget_class->snapshot = adw_indicator_bin_snapshot;
+  widget_class->unrealize = adw_indicator_bin_unrealize;
 
   /**
    * AdwIndicatorBin:child:


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