summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-03-30 20:56:37 +0000
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2024-04-02 03:40:25 +0200
commit19b6d9c470e1b6b9c8b555aaee119425c8837852 (patch)
tree8f3ee3d13d292b078d5b57f13db910fe7dc199f5
parent87ef871a777b1d44486ae51e536c95a0b5c49e67 (diff)
Resolves: tdf#157258 "Always autocorrect to" deletes the word
instead of replacing it, affecting extensions like Grammalecte, LanguageTool, Antidote this began in: commit afa35742a4633db31b6d6c72cf45741506e9edfb Date: Sat Dec 11 21:09:39 2021 +0000 prefer more css::awt::XPopupMenu api but the underlying trap was introduced in: commit 6c84dc18062ec6aad71fd65a409373c274402991 Date: Wed Oct 6 10:16:39 2010 +0100 initial commit for vba blob ( not including container_control stuff ) which added creating a VCLXPopupMenu in VCLXMenu::getPopupMenu if there was a vcl PopupMenu in the vcl Menu which hadn't been created by calling VCLXMenu::setPopupMenu. That didn't take into account that VCLXPopupMenu (like VCLXMenu) takes ownership of the PopupMenu and will destroy it in its own dtor, so the sub menu Popup get destroyed if the VCLXPopupMenu is shorter lived than the VCLXMenu wrapping the parent Menu. Change-Id: Ic28c27670d846ee9d2ff77d834e43fc157924eb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165484 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 161bcfa1c8687570acde0947b0350c70e7021d85) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165613
-rw-r--r--toolkit/source/awt/vclxmenu.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index f8c662ae2480..7e7fb471ab22 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -412,11 +412,30 @@ css::uno::Reference< css::awt::XPopupMenu > VCLXMenu::getPopupMenu(
break;
}
}
- // it seems the popup menu is not insert into maPopupMenuRefs
- // if the popup men is not created by stardiv.Toolkit.VCLXPopupMenu
+ /*
+ If the popup menu is not inserted via setPopupMenu then
+ maPopupMenuRefs won't have an entry for it, so create an XPopupMenu
+ for it now.
+
+ This means that this vcl PopupMenu "pMenu" either existed as a child
+ of the vcl Menu "mpMenu" before the VCLXMenu was created for that or
+ it was added directly via vcl.
+ */
if( !aRef.is() )
{
aRef = new VCLXPopupMenu( static_cast<PopupMenu*>(pMenu) );
+ /*
+ In any case, the VCLXMenu has ownership of "mpMenu" and will
+ destroy it in the VCLXMenu dtor.
+
+ Similarly because VCLXPopupMenu takes ownership of the vcl
+ PopupMenu "pMenu", the underlying vcl popup will be destroyed
+ when VCLXPopupMenu is, so we should add it now to
+ maPopupMenuRefs to ensure its lifecycle is at least bound to
+ the VCLXMenu that owns the parent "mpMenu" similarly to
+ PopupMenus added via the more conventional setPopupMenu.
+ */
+ maPopupMenuRefs.push_back( aRef );
}
}
return aRef;