summaryrefslogtreecommitdiff
path: root/basctl/source/basicide
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-17 15:56:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-17 20:49:37 +0200
commitba257c8443e3b66f73737895f68e57b7cd1c7cb2 (patch)
treeaaa8f284750e5c4e9b7fdcfbd2f7fb4971069c29 /basctl/source/basicide
parent1f8795df957c18c5c06bf1d68d0d60b1d30f015d (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/+/134484 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl/source/basicide')
-rw-r--r--basctl/source/basicide/moduldlg.cxx7
1 files changed, 7 insertions, 0 deletions
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<Entry*>(sId))
+ {
+ assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT);
+ std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry));
+ sId = weld::toId(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)