diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-30 20:56:37 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-31 12:01:27 +0200 |
commit | 7f7a7cf0eca793a9efb8456f96ccfece07f6f9d9 (patch) | |
tree | 95dd28b510b9f9da241367147319ac0423110869 /toolkit | |
parent | da4f91bd4042f2c0ddd65c76d4ad5c35dbf3e1aa (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/+/165582
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxmenu.cxx | 23 |
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; |