[gtk+/wip/matthiasc/font-variations: 258/260] Fix memory handling for axes



commit 125f38160b1c60540bee545a9de9b7f9fb27a4b1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 17 22:59:49 2017 -0500

    Fix memory handling for axes
    
    When the dialog is finalized, the axis widgets are already destroyed
    as part of the widget hierarchy, so we can't do that in the axis_free
    function. Instead, do it separately.

 gtk/gtkfontchooserwidget.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 943badb..86e108f 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -209,13 +209,22 @@ axis_equal (gconstpointer v1, gconstpointer v2)
 }
 
 static void
-axis_free (gpointer v)
+axis_remove (gpointer key,
+             gpointer value,
+             gpointer data)
 {
-  Axis *a = v;
+  Axis *a = value;
 
   gtk_widget_destroy (a->label);
   gtk_widget_destroy (a->scale);
   gtk_widget_destroy (a->spin);
+}
+
+static void
+axis_free (gpointer v)
+{
+  Axis *a = v;
+
   g_free (a);
 }
 
@@ -1431,6 +1440,7 @@ gtk_font_chooser_widget_update_font_variations (GtkFontChooserWidget *fontchoose
   if (priv->updating_variations)
     return;
 
+  g_hash_table_foreach (priv->axes, axis_remove, NULL);
   g_hash_table_remove_all (priv->axes);
 
   pango_font = pango_context_load_font (gtk_widget_get_pango_context (GTK_WIDGET (fontchooser)),


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