Bugzilla – Attachment 248228 Details for
Bug 402256
main-menu process high cpu usage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
[patch]
gnome-main-menu-leaks.diff
gnome-main-menu-leaks.diff (text/plain), 13.18 KB, created by
Federico Mena Quintero
on 2008-10-28 01:28:20 UTC
(
hide
)
Description:
gnome-main-menu-leaks.diff
Filename:
MIME Type:
Creator:
Federico Mena Quintero
Created:
2008-10-28 01:28:20 UTC
Size:
13.18 KB
patch
obsolete
>From 1c7de853039fb28189a31eab87b5e722be0852d5 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 11:36:08 -0600 >Subject: [PATCH 1/8] Don't leak menus attached to tiles > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > libslab/ChangeLog | 9 +++++++++ > libslab/tile.c | 23 ++++++++++++++++++++--- > 2 files changed, 29 insertions(+), 3 deletions(-) > >diff --git a/libslab/ChangeLog b/libslab/ChangeLog >index 56e381c..3329e35 100644 >--- a/libslab/ChangeLog >+++ b/libslab/ChangeLog >@@ -1,3 +1,12 @@ >+2008-10-27 Federico Mena Quintero <federico@novell.com> >+ >+ Fix a possible leak of menus: >+ >+ * tile.c (tile_finalize): Actually destroy the context menu, don't >+ ref/sink it. >+ (tile_set_property): Attach the context menu to the tile, don't >+ just store its pointer. >+ > 2008-09-22 Scott Reeves <sreeves@novell.com> > * document-tile.c: > show remote docs - use gio for tooltip, show icon >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: >-- >1.5.6 > > >From 544d8167db528dec6988bc548f8f11ffb4564284 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 11:59:47 -0600 >Subject: [PATCH 2/8] Free the tooltips when a tile is freed > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > libslab/ChangeLog | 4 +++- > libslab/nameplate-tile.c | 9 +++++++++ > 2 files changed, 12 insertions(+), 1 deletions(-) > >diff --git a/libslab/ChangeLog b/libslab/ChangeLog >index 3329e35..10fa914 100644 >--- a/libslab/ChangeLog >+++ b/libslab/ChangeLog >@@ -1,12 +1,14 @@ > 2008-10-27 Federico Mena Quintero <federico@novell.com> > >- Fix a possible leak of menus: >+ Fix some memory leaks: > > * tile.c (tile_finalize): Actually destroy the context menu, don't > ref/sink it. > (tile_set_property): Attach the context menu to the tile, don't > just store its pointer. > >+ * nameplate-tile.c (nameplate_tile_finalize): Free the tooltips. >+ > 2008-09-22 Scott Reeves <sreeves@novell.com> > * document-tile.c: > show remote docs - use gio for tooltip, show icon >diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c >index 23362e4..f7a0bf5 100644 >--- a/libslab/nameplate-tile.c >+++ b/libslab/nameplate-tile.c >@@ -117,6 +117,15 @@ 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); >+ >+ if (priv->tooltips) >+ gtk_object_destroy (GTK_OBJECT (priv->tooltips)); >+ > (*G_OBJECT_CLASS (nameplate_tile_parent_class)->finalize) (g_object); > } > >-- >1.5.6 > > >From dd74eda1e56828f8334054f71d8eb2badd6d55df Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 14:01:14 -0600 >Subject: [PATCH 3/8] Count the number of created/destroyed tooltips > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > libslab/nameplate-tile.c | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) > >diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c >index f7a0bf5..3d2e77d 100644 >--- a/libslab/nameplate-tile.c >+++ b/libslab/nameplate-tile.c >@@ -123,8 +123,13 @@ nameplate_tile_finalize (GObject * g_object) > np_tile = NAMEPLATE_TILE (g_object); > priv = NAMEPLATE_TILE_GET_PRIVATE (np_tile); > >- if (priv->tooltips) >+ if (priv->tooltips) { >+ static int num_destroyed_tooltips; >+ > gtk_object_destroy (GTK_OBJECT (priv->tooltips)); >+ num_destroyed_tooltips++; >+ printf ("Destroyed tooltips: %d\n", num_destroyed_tooltips); >+ } > > (*G_OBJECT_CLASS (nameplate_tile_parent_class)->finalize) (g_object); > } >@@ -239,8 +244,13 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v > > case PROP_NAMEPLATE_TOOLTIP: > if (tooltip) { >- if (! priv->tooltips) >+ if (! priv->tooltips) { >+ static int num_created_tooltips; >+ > priv->tooltips = gtk_tooltips_new (); >+ num_created_tooltips++; >+ printf ("Created tooltips: %d\n", num_created_tooltips); >+ } > > gtk_tooltips_set_tip (priv->tooltips, GTK_WIDGET(this), tooltip, tooltip); > gtk_tooltips_enable(priv->tooltips); >-- >1.5.6 > > >From f55fc8d0c50043df2a9e8ec98de326cf8f355252 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 14:05:01 -0600 >Subject: [PATCH 4/8] Free some strings > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > libslab/ChangeLog | 4 ++++ > libslab/bookmark-agent.c | 6 ++++++ > 2 files changed, 10 insertions(+), 0 deletions(-) > >diff --git a/libslab/ChangeLog b/libslab/ChangeLog >index 10fa914..3506684 100644 >--- a/libslab/ChangeLog >+++ b/libslab/ChangeLog >@@ -9,6 +9,10 @@ > > * nameplate-tile.c (nameplate_tile_finalize): Free the tooltips. > >+ * bookmark-agent.c (create_app_item): Free the URI. >+ (create_doc_item): Likewise. >+ (create_dir_item): Likewise. >+ > 2008-09-22 Scott Reeves <sreeves@novell.com> > * document-tile.c: > show remote docs - use gio for tooltip, show icon >diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c >index 47dc6bc..20d8379 100644 >--- a/libslab/bookmark-agent.c >+++ b/libslab/bookmark-agent.c >@@ -1063,6 +1063,8 @@ create_app_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 >@@ -1121,6 +1123,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 +1208,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 >-- >1.5.6 > > >From 33edc7368a49c7b6969f0a99d4dfd02292487809 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 14:14:41 -0600 >Subject: [PATCH 5/8] Don't leak the size group used for icons in a tile-table > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > ChangeLog | 8 ++++++++ > main-menu/src/tile-table.c | 11 +++++++---- > 2 files changed, 15 insertions(+), 4 deletions(-) > >diff --git a/ChangeLog b/ChangeLog >index 0310e86..d1eab6e 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,11 @@ >+2008-10-27 Federico Mena Quintero <federico@novell.com> >+ >+ * main-menu/src/tile-table.c (TileTablePrivate): Add an >+ icon_size_group field. >+ (tile_table_reload): Remember the size group we use for icons, >+ instead of creating it (and leaking it) every time. >+ (finalize): Free the icon_size_group. >+ > 2008-09-12 Scott Reeves <sreeves@novell.com> > * configure.in: post release bump to 0.9.12 > >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); >-- >1.5.6 > > >From 507203225719a2d8c39a08b5ac1c13fd39e41a60 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 15:08:49 -0600 >Subject: [PATCH 6/8] Fix leak in when creating the recently-used monitor > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > ChangeLog | 3 +++ > main-menu/src/main-menu-ui.c | 1 + > 2 files changed, 4 insertions(+), 0 deletions(-) > >diff --git a/ChangeLog b/ChangeLog >index d1eab6e..9323088 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,5 +1,8 @@ > 2008-10-27 Federico Mena Quintero <federico@novell.com> > >+ * main-menu/src/main-menu-ui.c >+ (setup_recently_used_store_monitor): Free the path. >+ > * main-menu/src/tile-table.c (TileTablePrivate): Add an > icon_size_group field. > (tile_table_reload): Remember the size group we use for icons, >diff --git a/main-menu/src/main-menu-ui.c b/main-menu/src/main-menu-ui.c >index d212eef..1684050 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) { >-- >1.5.6 > > >From 67cc693e776253a1bdcd4ccbdff42ae657f46e24 Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 15:10:17 -0600 >Subject: [PATCH 7/8] Fix file leak in when creating the recently-used monitor > >Signed-off-by: Federico Mena Quintero <federico@novell.com> >--- > ChangeLog | 1 + > main-menu/src/main-menu-ui.c | 2 ++ > 2 files changed, 3 insertions(+), 0 deletions(-) > >diff --git a/ChangeLog b/ChangeLog >index 9323088..dad7d33 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -2,6 +2,7 @@ > > * main-menu/src/main-menu-ui.c > (setup_recently_used_store_monitor): Free the path. >+ (setup_recently_used_store_monitor): Unref the file. > > * main-menu/src/tile-table.c (TileTablePrivate): Add an > icon_size_group field. >diff --git a/main-menu/src/main-menu-ui.c b/main-menu/src/main-menu-ui.c >index 1684050..0b0248c 100644 >--- a/main-menu/src/main-menu-ui.c >+++ b/main-menu/src/main-menu-ui.c >@@ -1012,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) >-- >1.5.6 > > >From 1860ee9b460db4484a6557c481169f0c1ba6defd Mon Sep 17 00:00:00 2001 >From: Federico Mena Quintero <federico@novell.com> >Date: Mon, 27 Oct 2008 15:52:46 -0600 >Subject: [PATCH 8/8] Print new and deleted tiles > >--- > libslab/nameplate-tile.c | 10 ++-------- > 1 files changed, 2 insertions(+), 8 deletions(-) > >diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c >index 3d2e77d..53fcff7 100644 >--- a/libslab/nameplate-tile.c >+++ b/libslab/nameplate-tile.c >@@ -124,11 +124,8 @@ nameplate_tile_finalize (GObject * g_object) > priv = NAMEPLATE_TILE_GET_PRIVATE (np_tile); > > if (priv->tooltips) { >- static int num_destroyed_tooltips; >- > gtk_object_destroy (GTK_OBJECT (priv->tooltips)); >- num_destroyed_tooltips++; >- printf ("Destroyed tooltips: %d\n", num_destroyed_tooltips); >+ printf ("del: %p\n", np_tile); > } > > (*G_OBJECT_CLASS (nameplate_tile_parent_class)->finalize) (g_object); >@@ -245,11 +242,8 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v > case PROP_NAMEPLATE_TOOLTIP: > if (tooltip) { > if (! priv->tooltips) { >- static int num_created_tooltips; >- > priv->tooltips = gtk_tooltips_new (); >- num_created_tooltips++; >- printf ("Created tooltips: %d\n", num_created_tooltips); >+ printf ("new: %p (%s)\n", this, tooltip); > } > > gtk_tooltips_set_tip (priv->tooltips, GTK_WIDGET(this), tooltip, tooltip); >-- >1.5.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 402256
:
226200
|
226231
|
230317
|
232385
|
247701
|
248215
|
248228
|
250505