[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 2 commits - sw/source
Tor Lillqvist
tml at kemper.freedesktop.org
Thu Jun 9 07:42:38 PDT 2011
sw/source/core/doc/docbm.cxx | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
New commits:
commit 4a2d8af43d7408aa037f1afc9ec819a363c02278
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jun 9 15:25:49 2011 +0100
fdo#37974 make recursive call of MarkManager::deleteMark do the right thing
Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index e688cbc..f79374c 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -720,6 +720,19 @@ namespace sw { namespace mark
//position as const iterator ppMark was
iterator_t aI = m_vMarks.begin();
std::advance(aI, std::distance<const_iterator_t>(aI, ppMark));
+
+ //fdo#37974
+ //a) a mark destructor may callback into this method.
+ //b) vector::erase first calls the destructor of the object, then
+ //removes it from the vector.
+ //So if the only reference to the object is the one
+ //in the vector then we may reenter this method when the mark
+ //is destructed but before it is removed, i.e. findMark still
+ //finds the object whose destructor is being run. Take a temp
+ //extra reference on the shared_ptr, remove the entry from the
+ //vector, and on xHoldPastErase release findMark won't find
+ //it anymore.
+ pMark_t xHoldPastErase = *aI;
m_vMarks.erase(aI);
}
commit 0e3b3cc3c3b94ef2f470be68d83129e9ed5f6fca
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 8 10:23:22 2011 +0100
Effective STL Item 27
Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 5a3cf3e..e688cbc 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -716,7 +716,11 @@ namespace sw { namespace mark
DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(ppMark->get());
if(pDdeBookmark)
pDdeBookmark->DeregisterFromDoc(m_pDoc);
- m_vMarks.erase(m_vMarks.begin() + (ppMark - m_vMarks.begin())); // clumsy const-cast
+ //Effective STL Item 27, get a non-const iterator aI at the same
+ //position as const iterator ppMark was
+ iterator_t aI = m_vMarks.begin();
+ std::advance(aI, std::distance<const_iterator_t>(aI, ppMark));
+ m_vMarks.erase(aI);
}
void MarkManager::deleteMark(const IMark* const pMark)
More information about the Libreoffice-commits
mailing list