diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-17 15:56:17 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-05-18 11:03:03 +0200 |
commit | 5d2f16b0ae25949a0f466c30357fd591fa7276d9 (patch) | |
tree | ec7752f7be03b43249e36f438940c9897cf45acd | |
parent | 425c1e3f31b49049ad8a6985d4c11e325b7e4750 (diff) |
Related: tdf#145722 need to clone userdata if we copy a module/dialog
otherwise we double-free it, so do what TreeListBox::CloneEntry used to
before it was dropped as unused at
commit 4a72d6f474b105cdaa7a570b1f199475cc64bb14
Date: Tue Feb 11 13:50:50 2020 +0000
drop newly unused TreeListBox
Change-Id: I127511ef4f752cf9a2da26a541e6f1add2a9cf9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134439
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 2e3c8c2530d1..582a08740d28 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -496,6 +496,13 @@ private: OUString sText(m_rTreeView.get_text(*xSelected)); OUString sId(m_rTreeView.get_id(*xSelected)); + /// if copying then clone the userdata + if (Entry* pEntry = bMove ? nullptr : reinterpret_cast<Entry*>(sId.toUInt64())) + { + assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT); + std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry)); + sId = OUString::number(reinterpret_cast<sal_uInt64>(xNewUserData.release())); + } std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator()); m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, &sText, &sId, nullptr, nullptr, false, xRet.get()); if (eType == OBJ_TYPE_MODULE) |