summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArul Michael <arul71.m@gmail.com>2016-02-22 09:53:31 +0530
committerEike Rathke <erack@redhat.com>2016-03-03 19:05:01 +0000
commita6e7673aec0321ceb328de902d5ee0689df3abf7 (patch)
tree7212306de2d8f4d9f57ea8e391f94548f3d58f43
parent9c473d38885e74b5a48ccd54b1f3e30b01a710d2 (diff)
tdf#97215 Sorting with update reference causes crash
The memory of SvtBroadcaster* of a cell is freed in EndlisteningCell() during SplitFormulaGroups call. The same memory address is assigned back to the cell again when the contents are transferred back after sorting. This is because the CreateSortinfoArray is done before SplitformulaGroup. For fix getting mpbroadcaster from the Document instead of SortinfoArray since we change the broadcaster in document after creating the SortInfoArray. Change-Id: Ic492d5019e26ff204307db4fefccc48ec99c0a6d Reviewed-on: https://gerrit.libreoffice.org/22607 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> (cherry picked from commit fca1147953989ef26e641e2ee9bb7e6390a69dd6) Reviewed-on: https://gerrit.libreoffice.org/22877
-rw-r--r--sc/source/core/data/table3.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index ee760802ac38..2671fde9e678 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -231,11 +231,10 @@ public:
{
ScRefCellValue maCell;
const sc::CellTextAttr* mpAttr;
- const SvtBroadcaster* mpBroadcaster;
const ScPostIt* mpNote;
const ScPatternAttr* mpPattern;
- Cell() : mpAttr(nullptr), mpBroadcaster(nullptr), mpNote(nullptr), mpPattern(nullptr) {}
+ Cell() : mpAttr(nullptr), mpNote(nullptr), mpPattern(nullptr) {}
};
struct Row
@@ -438,10 +437,8 @@ void initDataRows(
{
ScSortInfoArray::Row& rRow = *rRows[nRow-nRow1];
ScSortInfoArray::Cell& rCell = rRow.maCells[nCol-nCol1];
-
rCell.maCell = rCol.GetCellValue(aBlockPos, nRow);
rCell.mpAttr = rCol.GetCellTextAttr(aBlockPos, nRow);
- rCell.mpBroadcaster = rCol.GetBroadcaster(aBlockPos, nRow);
rCell.mpNote = rCol.GetCellNote(aBlockPos, nRow);
if (!bUniformPattern && bPattern)
@@ -709,10 +706,11 @@ void fillSortedColumnArray(
std::vector<std::unique_ptr<SortedColumn>>& rSortedCols,
SortedRowFlags& rRowFlags,
std::vector<SvtListener*>& rCellListeners,
- ScSortInfoArray* pArray, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress )
+ ScSortInfoArray* pArray, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress, const ScTable* pTable )
{
SCROW nRow1 = pArray->GetStart();
ScSortInfoArray::RowsType* pRows = pArray->GetDataRows();
+ std::vector<SCCOLROW> aOrderIndices = pArray->GetOrderIndices();
size_t nColCount = nCol2 - nCol1 + 1;
std::vector<std::unique_ptr<SortedColumn>> aSortedCols; // storage for copied cells.
@@ -795,10 +793,11 @@ void fillSortedColumnArray(
// At this point each broadcaster instance is managed by 2
// containers. We will release those in the original storage
// below before transferring them to the document.
+ const SvtBroadcaster* pBroadcaster = pTable->GetBroadcaster( nCol1 + j, aOrderIndices[i]);
sc::BroadcasterStoreType& rBCStore = aSortedCols.at(j).get()->maBroadcasters;
- if (rCell.mpBroadcaster)
+ if (pBroadcaster)
// A const pointer would be implicitly converted to a bool type.
- rBCStore.push_back(const_cast<SvtBroadcaster*>(rCell.mpBroadcaster));
+ rBCStore.push_back(const_cast<SvtBroadcaster*>(pBroadcaster));
else
rBCStore.push_back_empty();
}
@@ -1091,7 +1090,7 @@ void ScTable::SortReorderByRow(
// a copy before updating the document.
std::vector<std::unique_ptr<SortedColumn>> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags;
- fillSortedColumnArray(aSortedCols, aRowFlags, aCellListeners, pArray, nTab, nCol1, nCol2, pProgress);
+ fillSortedColumnArray(aSortedCols, aRowFlags, aCellListeners, pArray, nTab, nCol1, nCol2, pProgress, this);
for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{
@@ -1277,7 +1276,7 @@ void ScTable::SortReorderByRowRefUpdate(
std::vector<std::unique_ptr<SortedColumn>> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags;
std::vector<SvtListener*> aListenersDummy;
- fillSortedColumnArray(aSortedCols, aRowFlags, aListenersDummy, pArray, nTab, nCol1, nCol2, pProgress);
+ fillSortedColumnArray(aSortedCols, aRowFlags, aListenersDummy, pArray, nTab, nCol1, nCol2, pProgress, this);
for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{