[Libreoffice-commits] core.git: vcl/unx

Matthew J. Francis mjay.francis at gmail.com
Tue Sep 30 06:06:54 PDT 2014


 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 9db2eeea92d3a1e0571ae91eb74e218662732be9
Author: Matthew J. Francis <mjay.francis at gmail.com>
Date:   Mon Sep 29 12:38:05 2014 +0800

    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 at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index ee623bc..bab4f5c 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 );


More information about the Libreoffice-commits mailing list