From ba257c8443e3b66f73737895f68e57b7cd1c7cb2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 17 May 2022 15:56:17 +0100 Subject: Related: tdf#145722 need to clone userdata if we copy a module/dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/+/134484 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- basctl/source/basicide/moduldlg.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'basctl') diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 114a9e2062fa..3d5ead6d0259 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 : weld::fromId(sId)) + { + assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT); + std::unique_ptr xNewUserData(std::make_unique(*pEntry)); + sId = weld::toId(xNewUserData.release()); + } std::unique_ptr 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) -- cgit