summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-10 12:53:52 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-10 17:42:17 +0100
commit951d9fe0b5470085ae817c3af04014e6dd95b498 (patch)
treee71a7100a213687165e251149b053d0fa282d8e2
parent85ed3a47ed8427f41081b5a579ad237c5720cbe8 (diff)
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>
-rw-r--r--vcl/unx/gtk3/gtk3gtksalmenu.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/vcl/unx/gtk3/gtk3gtksalmenu.cxx b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
index e81222b69482..3ed2487ff4f3 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();
}