RE: Patch to fix a hildon-1 bug



it's already in maemo Bugzilla.
Basically it's caused by different memory allocator. Please see
https://bugs.maemo.org/show_bug.cgi?id=1276.

I polished original patch. see below.

diff --git a/src/hildon-window.c b/src/hildon-window.c
index 1f1fac6..b0bc4d3 100644
--- a/src/hildon-window.c
+++ b/src/hildon-window.c
@@ -380,8 +380,8 @@ hildon_window_finalize
(GObject * obj_self)
     
     self = HILDON_WINDOW (obj_self);
 
-    g_free (priv->borders);
-    g_free (priv->toolbar_borders);
+    gtk_border_free(priv->borders);
+    gtk_border_free(priv->toolbar_borders);
 
     if (G_OBJECT_CLASS (parent_class)->finalize)
         G_OBJECT_CLASS (parent_class)->finalize (obj_self);
@@ -486,18 +486,20 @@ hildon_window_get_borders
(HildonWindow *window)
     HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (window);
     g_assert (priv);
 
-    g_free (priv->borders);
-    g_free (priv->toolbar_borders);
+    gtk_border_free (priv->borders);
+    gtk_border_free (priv->toolbar_borders);
+    priv->borders = NULL;
+    priv->toolbar_borders = NULL;      
 
     gtk_widget_style_get (GTK_WIDGET (window),
"borders",&priv->borders,
             "toolbar-borders", &priv->toolbar_borders,
             NULL);
 
     if (! priv->borders)
-        priv->borders = (GtkBorder *) g_malloc0 (sizeof (GtkBorder));
+        priv->borders = (GtkBorder *) g_slice_new0 (GtkBorder);
 
-    if (! priv->toolbar_borders)
-        priv->toolbar_borders = (GtkBorder *) g_malloc0 (sizeof
(GtkBorder));
+    if (! priv->toolbar_borders) 
+        priv->toolbar_borders = (GtkBorder *) g_slice_new0 (GtkBorder);
 }
 

Zhu, Peter J wrote:
> Hi,
> 
> Here I send a patch at end of this mail to fix a hildon-1 bug that
> will cause program crash as hildon window is destroied in some
> cases(Specially the it returns FALSE in the delete-event processing of
> that windo).
> 
> Basically, the GtkBorder widget should be freed with gtk_border_free()
> rather than using g_free if it's NOT created by g_malloc.
> 



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