File gnome-main-menu-bnc402256-leaks.diff of Package gnome-main-menu
bnc402256 - Fix memory leaks when refreshing the recent files list and bookmarks.
diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c
index 47dc6bc..93efd23 100644
--- a/libslab/bookmark-agent.c
+++ b/libslab/bookmark-agent.c
@@ -1061,8 +1061,12 @@ create_app_item (BookmarkAgent *this, const gchar *uri)
else if (! libslab_strcmp (name, "Shutdown"))
g_bookmark_file_set_title (priv->store, uri, _("Shutdown"));
+ g_free (name);
+
if (libslab_strcmp (uri, uri_new))
g_bookmark_file_move_item (priv->store, uri, uri_new, NULL);
+
+ g_free (uri_new);
}
static void
@@ -1121,6 +1125,8 @@ create_doc_item (BookmarkAgent *this, const gchar *uri)
if (libslab_strcmp (uri, uri_new))
g_bookmark_file_move_item (priv->store, uri, uri_new, NULL);
+
+ g_free (uri_new);
}
static void
@@ -1204,6 +1210,8 @@ create_dir_item (BookmarkAgent *this, const gchar *uri)
if (uri_new && libslab_strcmp (uri, uri_new))
g_bookmark_file_move_item (priv->store, uri, uri_new, NULL);
+
+ g_free (uri_new);
}
static void
diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c
index 23362e4..fc2f661 100644
--- a/libslab/nameplate-tile.c
+++ b/libslab/nameplate-tile.c
@@ -36,7 +36,6 @@ typedef struct
GtkContainer *image_ctnr;
GtkContainer *header_ctnr;
GtkContainer *subheader_ctnr;
- GtkTooltips *tooltips;
} NameplateTilePrivate;
#define NAMEPLATE_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAMEPLATE_TILE_TYPE, NameplateTilePrivate))
@@ -100,7 +99,6 @@ nameplate_tile_class_init (NameplateTileClass * this_class)
static void
nameplate_tile_init (NameplateTile * this)
{
- NAMEPLATE_TILE_GET_PRIVATE (this)->tooltips = NULL;
}
static GObject *
@@ -117,6 +115,12 @@ nameplate_tile_constructor (GType type, guint n_param, GObjectConstructParam * p
static void
nameplate_tile_finalize (GObject * g_object)
{
+ NameplateTile *np_tile;
+ NameplateTilePrivate *priv;
+
+ np_tile = NAMEPLATE_TILE (g_object);
+ priv = NAMEPLATE_TILE_GET_PRIVATE (np_tile);
+
(*G_OBJECT_CLASS (nameplate_tile_parent_class)->finalize) (g_object);
}
@@ -124,7 +128,7 @@ static void
nameplate_tile_get_property (GObject * g_object, guint prop_id, GValue * value,
GParamSpec * param_spec)
{
- GtkTooltipsData *tooltip;
+ char *tooltip;
NameplateTile *np_tile = NAMEPLATE_TILE (g_object);
switch (prop_id)
@@ -141,8 +145,9 @@ nameplate_tile_get_property (GObject * g_object, guint prop_id, GValue * value,
g_value_set_object (value, np_tile->subheader);
break;
case PROP_NAMEPLATE_TOOLTIP:
- tooltip = gtk_tooltips_data_get (GTK_WIDGET (np_tile));
- g_value_set_string (value, tooltip ? tooltip->tip_text : NULL);
+ tooltip = gtk_widget_get_tooltip_text (GTK_WIDGET (np_tile));
+ g_value_set_string (value, tooltip);
+ g_free (tooltip);
break;
default:
@@ -229,17 +234,7 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v
break;
case PROP_NAMEPLATE_TOOLTIP:
- if (tooltip) {
- if (! priv->tooltips)
- priv->tooltips = gtk_tooltips_new ();
-
- gtk_tooltips_set_tip (priv->tooltips, GTK_WIDGET(this), tooltip, tooltip);
- gtk_tooltips_enable(priv->tooltips);
- }
- else
- if (priv->tooltips)
- gtk_tooltips_disable(priv->tooltips);
-
+ gtk_widget_set_tooltip_text (GTK_WIDGET (this), tooltip);
break;
diff --git a/libslab/tile.c b/libslab/tile.c
index 0505c36..870944d 100644
--- a/libslab/tile.c
+++ b/libslab/tile.c
@@ -209,7 +209,7 @@ tile_finalize (GObject * g_object)
if (tile->uri)
g_free (tile->uri);
if (tile->context_menu)
- gtk_object_sink (GTK_OBJECT (tile->context_menu));
+ gtk_widget_destroy (GTK_WIDGET (tile->context_menu));
g_object_unref (priv->double_click_detector);
@@ -240,17 +240,34 @@ tile_get_property (GObject * g_obj, guint prop_id, GValue * value, GParamSpec *
static void
tile_set_property (GObject * g_obj, guint prop_id, const GValue * value, GParamSpec * param_spec)
{
+ Tile *tile;
+ GtkMenu *menu;
+
if (!IS_TILE (g_obj))
return;
+ tile = TILE (g_obj);
+
switch (prop_id)
{
case PROP_TILE_URI:
- TILE (g_obj)->uri = g_strdup (g_value_get_string (value));
+ tile->uri = g_strdup (g_value_get_string (value));
break;
case PROP_TILE_CONTEXT_MENU:
- TILE (g_obj)->context_menu = g_value_get_object (value);
+ menu = g_value_get_object (value);
+
+ if (menu == tile->context_menu)
+ break;
+
+ if (tile->context_menu)
+ gtk_menu_detach (tile->context_menu);
+
+ tile->context_menu = menu;
+
+ if (tile->context_menu)
+ gtk_menu_attach_to_widget (tile->context_menu, GTK_WIDGET (tile), NULL);
+
break;
default:
diff --git a/main-menu/src/main-menu-ui.c b/main-menu/src/main-menu-ui.c
index d212eef..0b0248c 100644
--- a/main-menu/src/main-menu-ui.c
+++ b/main-menu/src/main-menu-ui.c
@@ -1001,6 +1001,7 @@ setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup)
path = get_recently_used_store_filename ();
file = g_file_new_for_path (path);
+ g_free (path);
monitor = g_file_monitor_file (file, 0, NULL, NULL);
if (monitor) {
@@ -1011,6 +1012,8 @@ setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup)
this);
}
+ g_object_unref (file);
+
priv->recently_used_store_monitor = monitor;
if (priv->recently_used_timeout_id != 0)
diff --git a/main-menu/src/tile-table.c b/main-menu/src/tile-table.c
index 5b368e6..cbb6bdd 100644
--- a/main-menu/src/tile-table.c
+++ b/main-menu/src/tile-table.c
@@ -30,6 +30,7 @@ typedef struct {
BookmarkAgent *agent;
GList *tiles;
+ GtkSizeGroup *icon_size_group;
GtkBin **bins;
gint n_bins;
@@ -119,8 +120,6 @@ tile_table_reload (TileTable *this)
GtkWidget *tile;
gint n_tiles;
- GtkSizeGroup *icon_size_group;
-
GList *node;
gint i;
@@ -144,7 +143,8 @@ tile_table_reload (TileTable *this)
priv->tiles = NULL;
- icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ if (!priv->icon_size_group)
+ priv->icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
for (node = tiles; node; node = node->next) {
tile = GTK_WIDGET (node->data);
@@ -161,7 +161,7 @@ tile_table_reload (TileTable *this)
priv->tiles = g_list_append (priv->tiles, tile);
if (IS_NAMEPLATE_TILE (tile))
- gtk_size_group_add_widget (icon_size_group, NAMEPLATE_TILE (tile)->image);
+ gtk_size_group_add_widget (priv->icon_size_group, NAMEPLATE_TILE (tile)->image);
}
g_list_free (tiles);
@@ -343,6 +343,9 @@ finalize (GObject *g_obj)
{
TileTablePrivate *priv = PRIVATE (g_obj);
+ if (priv->icon_size_group)
+ g_object_unref (priv->icon_size_group);
+
g_free (priv->bins);
G_OBJECT_CLASS (tile_table_parent_class)->finalize (g_obj);