basctl/source/basicide/moduldlg.cxx |    7 +++++++
 1 file changed, 7 insertions(+)

New commits:
commit 5d2f16b0ae25949a0f466c30357fd591fa7276d9
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue May 17 15:56:17 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed May 18 11:03:03 2022 +0200

    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 <[email protected]>

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)

Reply via email to