Resolves: tdf#140225 remove action when item is removed from GtkSalMenu
and we have previously ensured that all items are removed by
Menu::dispose before GtkSalMenu dtor is called
Change-Id: Id91cfb96a16dfa7c55bb8bc6676cb7921ec8dd37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110704
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtksalmenu.cxx b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
index e81222b..3ed2487 100644
--- a/vcl/unx/gtk3/gtk3gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
@@ -596,23 +596,15 @@ GtkSalMenu::~GtkSalMenu()
{
SolarMutexGuard aGuard;
if (mpActionGroup)
{
// tdf#140225 if any menu is deleted clear the action-group shared
// by the hierarchy
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP(mpActionGroup);
g_lo_action_group_clear(pActionGroup);
// and flag the hierarchy as needing an update
SetNeedsUpdate();
}
// tdf#140225 we expect all items to be removed by Menu::dispose
// before this dtor is called
assert(maItems.empty());
DestroyMenuBarWidget();
if (mpMenuModel)
g_object_unref(mpMenuModel);
maItems.clear();
if (mpFrame)
mpFrame->SetMenu(nullptr);
}
@@ -640,6 +632,16 @@ void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
void GtkSalMenu::RemoveItem( unsigned nPos )
{
SolarMutexGuard aGuard;
// tdf#140225 clear associated action when the item is removed
if (mpActionGroup)
{
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP(mpActionGroup);
gchar* pCommand = GetCommandForItem(maItems[nPos]);
g_lo_action_group_remove(pActionGroup, pCommand);
g_free(pCommand);
}
maItems.erase( maItems.begin() + nPos );
SetNeedsUpdate();
}