summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/window/gtksalmenu.cxx
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-09-17 14:43:03 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:48 +0100
commitc8367ada13be4f3c0994ad032c09ea475e02a19a (patch)
tree793849d7b989a88291c85e69486647a6f3559e17 /vcl/unx/gtk/window/gtksalmenu.cxx
parentc1bf7fd49db152b16cf07e7060338a6bc27d9e0d (diff)
Improved memory management of GLOActionGroup.
Change-Id: Iaeee32c2990cb6514605d3f7bc959682d87d5d38
Diffstat (limited to 'vcl/unx/gtk/window/gtksalmenu.cxx')
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 94e13a1dba07..ad77c624bd61 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -346,6 +346,9 @@ on_registrar_available (GDBusConnection * /*connection*/,
if ( gdkWindow != NULL )
{
+ GMenuModel* pMenuModel = G_MENU_MODEL( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) );
+ GActionGroup* pActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) );
+
XLIB_Window windowId = GDK_WINDOW_XID( gdkWindow );
gchar* aDBusPath = g_strdup_printf("/window/%lu", windowId);
@@ -359,11 +362,11 @@ on_registrar_available (GDBusConnection * /*connection*/,
return;
// Publish the menu.
- if ( aDBusMenubarPath != NULL )
- g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pSalMenu->GetMenuModel(), NULL);
+ if ( aDBusMenubarPath != NULL && pMenuModel != NULL )
+ g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, NULL);
- if ( aDBusPath != NULL )
- g_dbus_connection_export_action_group( pSessionBus, aDBusPath, pSalMenu->GetActionGroup(), NULL);
+ if ( aDBusPath != NULL && pActionGroup != NULL )
+ g_dbus_connection_export_action_group( pSessionBus, aDBusPath, pActionGroup, NULL);
// Set window properties.
gdk_x11_window_set_utf8_property ( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) );
@@ -376,7 +379,9 @@ on_registrar_available (GDBusConnection * /*connection*/,
g_free( aDBusMenubarPath );
bDBusIsAvailable = sal_True;
- pMenuBar->SetDisplayable( sal_False );
+
+ if ( pMenuBar )
+ pMenuBar->SetDisplayable( sal_False );
}
}
@@ -545,8 +550,11 @@ void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItem
pCheckValue = g_variant_new_boolean( bCheck );
}
- if ( pCheckValue != NULL && ( pCurrentState == NULL || g_variant_equal( pCurrentState, pCheckValue) == FALSE ) )
+ if ( pCheckValue != NULL && ( pCurrentState == NULL || g_variant_equal( pCurrentState, pCheckValue ) == FALSE ) )
g_action_group_change_action_state( mpActionGroup, aCommand, pCheckValue );
+
+ if ( pCurrentState )
+ g_variant_unref( pCurrentState );
}
if ( aCommand )
@@ -563,7 +571,7 @@ void GtkSalMenu::NativeSetEnableItem( gchar* aCommand, gboolean bEnable )
void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText )
{
- // Replace the "~" character with "_".
+ // Replace the '~' character with '_'.
rtl::OUString aText = rText.replace( '~', '_' );
rtl::OString aConvertedText = OUStringToOString( aText, RTL_TEXTENCODING_UTF8 );