sw/source/uibase/inc/conttree.hxx | 2 +- sw/source/uibase/utlui/content.cxx | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-)
New commits: commit f7b102bc705d3bd98f7d2efa52c24eb6e2573642 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Mon Oct 14 12:22:05 2024 -0800 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Oct 15 19:29:56 2024 +0200 tdf#163191 Fix crash when dragging headings in Writer navigator by keeping track of the selected entry positions in SwOutlineNodes instead of iterators in the content tree. Change-Id: Iad0a477d6e3b25a1d602e3f827f2590c441eb236 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174912 Reviewed-by: Patrick Luby <guibomac...@gmail.com> Reviewed-by: Jim Raykowski <rayk...@gmail.com> Tested-by: Jenkins (cherry picked from commit dfeefe2e97a5412a445a3a508acb2d9ae05138e5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174942 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index d58123287e07..add857b4f84b 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -131,7 +131,7 @@ class SwContentTree final : public SfxListener bool m_bViewHasChanged :1; // outline root mode drag & drop - std::vector<std::unique_ptr<weld::TreeIter>> m_aDndOutlinesSelected; + std::vector<SwOutlineNodes::size_type> m_aDndOutlinesSelected; bool m_bDocHasChanged = true; bool m_bIgnoreDocChange = false; // used to prevent tracking update diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 07878125f241..52ef6d0967af 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1250,24 +1250,22 @@ IMPL_LINK(SwContentTree, DragBeginHdl, bool&, rUnsetDragIcon, bool) // Only move drag entry and continuous selected siblings: m_aDndOutlinesSelected.clear(); - std::unique_ptr<weld::TreeIter> xScratch(m_xTreeView->make_iterator()); + std::unique_ptr<weld::TreeIter> xScratch(m_xTreeView->make_iterator(xEntry.get())); // Find first selected of continuous siblings - while (true) + while (m_xTreeView->iter_previous_sibling(*xScratch) && m_xTreeView->is_selected(*xScratch)) { - m_xTreeView->copy_iterator(*xEntry, *xScratch); - if (!m_xTreeView->iter_previous_sibling(*xScratch)) - break; - if (!m_xTreeView->is_selected(*xScratch)) - break; m_xTreeView->copy_iterator(*xScratch, *xEntry); } // Record continuous selected siblings do { - m_aDndOutlinesSelected.push_back(m_xTreeView->make_iterator(xEntry.get())); - } - while (m_xTreeView->iter_next_sibling(*xEntry) && m_xTreeView->is_selected(*xEntry)); + SwOutlineContent* pOutlineContent + = weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(*xEntry)); + if (!pOutlineContent) // shouldn't happen + continue; + m_aDndOutlinesSelected.push_back(pOutlineContent->GetOutlinePos()); + } while (m_xTreeView->iter_next_sibling(*xEntry) && m_xTreeView->is_selected(*xEntry)); } rtl::Reference<TransferDataContainer> xContainer = new TransferDataContainer; @@ -4653,9 +4651,9 @@ void SwContentTree::MoveOutline(SwOutlineNodes::size_type nTargetPos) bool bFirstMove = true; - for (const auto& source : m_aDndOutlinesSelected) + for (const SwOutlineNodes::size_type& nPos : m_aDndOutlinesSelected) { - SwOutlineNodes::size_type nSourcePos = weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(*source))->GetOutlinePos(); + SwOutlineNodes::size_type nSourcePos = nPos; // Done on the first selection move if (bFirstMove) // only do once