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-03-31 20:49:32 +0200
commit161bcfa1c8687570acde0947b0350c70e7021d85 (patch)
tree0a872541edb0195672fba12a32b73340358d7e91
parent57428bfc71762687594c3c0fa62cdff391dda3f9 (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>
-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 20d3d5d2d18a..6515258861b4 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -413,11 +413,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;