summaryrefslogtreecommitdiff
path: root/sc/source/core/tool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-09-16 12:38:06 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-09-17 08:06:03 +0000
commita3014b097242a3647458ba4a6bc61facf5a9a3f0 (patch)
tree801b426de6a244c313545444b8bb5082d396a9a6 /sc/source/core/tool
parent4492a4cf9f37dc024c02ef00cccdd3b2262c5d80 (diff)
Resolves: tdf#94249 do not remove broadcasters while iterators are in use
EndListeningContext holds BroadcasterStoreType iterators in its ColumnBlockPositionSet and collects broadcasters to purge them at the end. Removing broadcasters from ScColumn::maBroadcasters in between invalidates the iterators. Hence calling the "normal" EndListening() that removes a broadcaster when all listeners are gone while an EndListeningContext is in use is bad. Change-Id: Ibdd88469e91e6173ceff1f391c23ef7cb7c6f596 (cherry picked from commit e4a8ae0bf54476e9a0c9e1f5348c05f3cd838899) Reviewed-on: https://gerrit.libreoffice.org/18618 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/core/tool')
-rw-r--r--sc/source/core/tool/sharedformula.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 84025b91fc04..5f3c399e9e90 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -18,7 +18,7 @@
namespace sc {
-void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type& aPos)
+void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt)
{
SCROW nRow = aPos.first->position + aPos.second;
@@ -63,7 +63,14 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
// other listeners, all listeners of this group's top cell are to be reset.
if (nLength2)
{
- rPrevTop.EndListeningTo( rPrevTop.GetDocument(), NULL, ScAddress( ScAddress::UNINITIALIZED));
+ // If a context exists it has to be used to not interfere with
+ // ScColumn::maBroadcasters iterators, which the EndListeningTo()
+ // without context would do when removing a broadcaster that had its
+ // last listener removed.
+ if (pCxt)
+ rPrevTop.EndListeningTo(*pCxt);
+ else
+ rPrevTop.EndListeningTo( rPrevTop.GetDocument(), NULL, ScAddress( ScAddress::UNINITIALIZED));
rPrevTop.SetNeedsListening(true);
}
#endif
@@ -109,7 +116,7 @@ void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vecto
if (aPos.first == rCells.end())
return;
- splitFormulaCellGroup(aPos);
+ splitFormulaCellGroup(aPos, nullptr);
std::vector<SCROW>::iterator itEnd = rBounds.end();
for (++it; it != itEnd; ++it)
{
@@ -118,7 +125,7 @@ void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vecto
if (aPos.first == rCells.end())
return;
- splitFormulaCellGroup(aPos);
+ splitFormulaCellGroup(aPos, nullptr);
}
}