Squash epic memory leak
StThemeNode holds a reference to its parent, but we never released that reference. This could cause us to hold onto whole chains of theme nodes with rather dire memory usage implications. Also move the other g_object_unref into _dispose. https://bugzilla.gnome.org/show_bug.cgi?id=614660
This commit is contained in:
parent
1ddb775d59
commit
44ede8c942
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
static void st_theme_node_init (StThemeNode *node);
|
static void st_theme_node_init (StThemeNode *node);
|
||||||
static void st_theme_node_class_init (StThemeNodeClass *klass);
|
static void st_theme_node_class_init (StThemeNodeClass *klass);
|
||||||
|
static void st_theme_node_dispose (GObject *object);
|
||||||
static void st_theme_node_finalize (GObject *object);
|
static void st_theme_node_finalize (GObject *object);
|
||||||
|
|
||||||
static const ClutterColor BLACK_COLOR = { 0, 0, 0, 0xff };
|
static const ClutterColor BLACK_COLOR = { 0, 0, 0, 0xff };
|
||||||
@ -27,9 +28,43 @@ st_theme_node_class_init (StThemeNodeClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = st_theme_node_dispose;
|
||||||
object_class->finalize = st_theme_node_finalize;
|
object_class->finalize = st_theme_node_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_theme_node_dispose (GObject *gobject)
|
||||||
|
{
|
||||||
|
StThemeNode *node = ST_THEME_NODE (gobject);
|
||||||
|
|
||||||
|
if (node->context)
|
||||||
|
{
|
||||||
|
g_object_unref (node->context);
|
||||||
|
node->context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->theme)
|
||||||
|
{
|
||||||
|
g_object_unref (node->theme);
|
||||||
|
node->theme = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->parent_node)
|
||||||
|
{
|
||||||
|
g_object_unref (node->parent_node);
|
||||||
|
node->parent_node = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->border_image)
|
||||||
|
{
|
||||||
|
g_object_unref (node->border_image);
|
||||||
|
node->border_image = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (st_theme_node_parent_class)->dispose (gobject);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_theme_node_finalize (GObject *object)
|
st_theme_node_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -59,12 +94,6 @@ st_theme_node_finalize (GObject *object)
|
|||||||
node->font_desc = NULL;
|
node->font_desc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->border_image)
|
|
||||||
{
|
|
||||||
g_object_unref (node->border_image);
|
|
||||||
node->border_image = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node->shadow)
|
if (node->shadow)
|
||||||
{
|
{
|
||||||
st_shadow_free (node->shadow);
|
st_shadow_free (node->shadow);
|
||||||
|
@ -253,6 +253,7 @@ st_widget_dispose (GObject *gobject)
|
|||||||
|
|
||||||
if (priv->theme_node)
|
if (priv->theme_node)
|
||||||
{
|
{
|
||||||
|
g_object_run_dispose (G_OBJECT (priv->theme_node));
|
||||||
g_object_unref (priv->theme_node);
|
g_object_unref (priv->theme_node);
|
||||||
priv->theme_node = NULL;
|
priv->theme_node = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user