summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew J. Francis <mjay.francis@gmail.com>2014-09-29 12:38:05 +0800
committerMichael Meeks <michael.meeks@collabora.com>2014-09-30 13:06:34 +0000
commit9db2eeea92d3a1e0571ae91eb74e218662732be9 (patch)
treed2e7c9fc45b0d18ece9d81295d6b3b7031e52c9b
parent3aa70e21d7d5fdbf68aebe90a4967ec8350db43f (diff)
Avoid leaking a GtkMenu
This is only freed on application exit, but in as far as there's a point to freeing it at all we should do it properly. Our handling of this GtkMenu is "unique" - it isn't owned by anything, and we paint it ourself manually. Therefore, in order to handle the refcounting correctly, we should sink the initially floating reference, and explicitly unreference it to finalise. Valgrind confirms that the leak is eliminated by doing this. Change-Id: I4c796c4d37dd8f514aff9768fab66168d36bae64 Reviewed-on: https://gerrit.libreoffice.org/11682 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index ee623bcd817b..bab4f5c6f888 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -489,7 +489,7 @@ void GtkData::deInitNWF( void )
if( gWidgetData[i].gCacheWindow )
gtk_widget_destroy( gWidgetData[i].gCacheWindow );
if( gWidgetData[i].gMenuWidget )
- gtk_widget_destroy( gWidgetData[i].gMenuWidget );
+ g_object_unref (gWidgetData[i].gMenuWidget);
if( gWidgetData[i].gTooltipPopup )
gtk_widget_destroy( gWidgetData[i].gTooltipPopup );
if( gWidgetData[i].gDialog )
@@ -4400,6 +4400,8 @@ static void NWEnsureGTKMenu( SalX11Screen nScreen )
gWidgetData[nScreen].gMenuItemSeparatorMenuWidget = gtk_menu_item_new();
gWidgetData[nScreen].gImageMenuItem = gtk_image_menu_item_new();
+ g_object_ref_sink (gWidgetData[nScreen].gMenuWidget);
+
gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemMenuWidget );
gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemCheckMenuWidget );
gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemRadioMenuWidget );