summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docbm.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc/docbm.cxx')
-rw-r--r--sw/source/core/doc/docbm.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index d38542922b52..c19d182c3f7a 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1285,13 +1285,28 @@ namespace sw::mark
// no special marks container
break;
}
- DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(pMark);
- if (pDdeBookmark)
- pDdeBookmark->DeregisterFromDoc(m_rDoc);
//Effective STL Item 27, get a non-const iterator aI at the same
//position as const iterator ppMark was
auto aI = m_vAllMarks.begin();
std::advance(aI, std::distance<container_t::const_iterator>(aI, ppMark.get()));
+ DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(pMark);
+ if (pDdeBookmark)
+ {
+ pDdeBookmark->DeregisterFromDoc(m_rDoc);
+
+ // Update aI, possibly a selection listener invalidated the iterators of m_vAllMarks.
+ auto [it, endIt] = equal_range(m_vAllMarks.begin(), m_vAllMarks.end(),
+ pMark->GetMarkStart(), CompareIMarkStartsBefore());
+ for (; it != endIt; ++it)
+ {
+ if (*it == pMark)
+ {
+ aI = m_vAllMarks.begin();
+ std::advance(aI, std::distance<container_t::const_iterator>(aI, it));
+ break;
+ }
+ }
+ }
m_vAllMarks.erase(aI);
// If we don't have a lazy deleter