vcl/unx/gtk/glomenu.cxx | 2 ++ vcl/unx/gtk/gtksalmenu.cxx | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-)
New commits: commit 1ef48f3bebe80a386490e2a0f8fd0ae40de07ada Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed Sep 14 14:09:18 2016 +0300 GtkSalMenu: Need a way to remove icons too e.g. user switches menu icons option off. Change-Id: I2a3f2c170f262a4542bfea24eb746f3aa405cbd6 diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 604a418..8671f4c 100644 --- a/vcl/unx/gtk/gtksalmenu.cxx +++ b/vcl/unx/gtk/gtksalmenu.cxx @@ -250,8 +250,7 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries) // Force updating of native menu labels. NativeSetItemText( nSection, nItemPos, aText ); - if (!!aImage) - NativeSetItemIcon( nSection, nItemPos, aImage ); + NativeSetItemIcon( nSection, nItemPos, aImage ); NativeSetAccelerator( nSection, nItemPos, nAccelKey, nAccelKey.GetName( GetFrame()->GetWindow() ) ); if ( g_strcmp0( aNativeCommand, "" ) != 0 && pSalMenuItem->mpSubMenu == nullptr ) @@ -870,19 +869,25 @@ void GtkSalMenu::NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const #if GLIB_CHECK_VERSION(2,38,0) SolarMutexGuard aGuard; - SvMemoryStream* pMemStm = new SvMemoryStream; - vcl::PNGWriter aWriter(rImage.GetBitmapEx()); - aWriter.Write(*pMemStm); + if (!!rImage) + { + SvMemoryStream* pMemStm = new SvMemoryStream; + vcl::PNGWriter aWriter(rImage.GetBitmapEx()); + aWriter.Write(*pMemStm); + + GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(), + pMemStm->Seek(STREAM_SEEK_TO_END), + DestroyMemoryStream, + pMemStm); - GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(), - pMemStm->Seek(STREAM_SEEK_TO_END), - DestroyMemoryStream, - pMemStm); + GIcon *pIcon = g_bytes_icon_new(pBytes); - GIcon *pIcon = g_bytes_icon_new(pBytes); - g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, pIcon ); - g_object_unref(pIcon); - g_bytes_unref(pBytes); + g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, pIcon ); + g_object_unref(pIcon); + g_bytes_unref(pBytes); + } + else + g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, nullptr ); #else (void)nSection; (void)nItemPos; commit ee8909ff066bb707c5d1234dc6d609bb5c0251f2 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Mon Sep 19 01:23:28 2016 +0300 Missing g_variant_unref because g_icon_serialize is calling g_variant_take_ref on it, followed by a g_variant_ref_sink call inside g_lo_menu_set_attribute_value. Change-Id: I1b68c64b6845f2f58b70c54f1b0f3f53141c1d5c diff --git a/vcl/unx/gtk/glomenu.cxx b/vcl/unx/gtk/glomenu.cxx index f91a469..2547c36 100644 --- a/vcl/unx/gtk/glomenu.cxx +++ b/vcl/unx/gtk/glomenu.cxx @@ -253,6 +253,8 @@ g_lo_menu_set_icon (GLOMenu *menu, #endif g_lo_menu_set_attribute_value (menu, position, G_MENU_ATTRIBUTE_ICON, value); + if (value) + g_variant_unref (value); } void _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits