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

New commits:
commit ba257c8443e3b66f73737895f68e57b7cd1c7cb2
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue May 17 15:56:17 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue May 17 20:49:37 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/+/134484
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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)

Reply via email to