summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-12-12 16:42:42 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-12-12 18:17:26 +0100
commit3e59716375a240576fd6d8759b32b4319506ed70 (patch)
tree38e7b751a4dbbc662aa64b06f8caed13c5e3ec3a /sc
parent40b0bd21e87480b659e7ed92854eee385a2a3c55 (diff)
Prevent BroadcastRecalcOnRefMoveHandler copies
...which would contain copies of AutoCalcSwitch and ScBulkBroadcast that both do things in their dtors. std::sort (into which BroadcastRecalcOnRefMoveHandler is passed as function object argument) returns its function object argument, which caused the BroadcastRecalcOnRefMoveHandler copies. Better split the RAII part that holds AutoCalcSwitch and ScBulkBroadcast and does things in their dtors into a BroadcastRecalcOnRefMoveGuard class of its own. (And while at it, explicitly delete the copy/move functions of AutoCalcSwitch and ScBulkBroadcast to avoid such issues in the future.) (The RAII part of BroadcastRecalcOnRefMoveHandler had been added with 60d0b992ea3a910be79ae4a8e8b0bb32a358b18a "sc-perf: tdf#87101 add bulk scope for BroadcastRecalcOnRefMove() calls". The issue was found with Clang 10 trunk -Wdeprecated-copy-dtor.) Change-Id: I45d6b81e7c8b34aed57b6f66c5e1e966a43a565d Reviewed-on: https://gerrit.libreoffice.org/85063 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scopetools.hxx6
-rw-r--r--sc/source/core/data/document.cxx25
-rw-r--r--sc/source/core/inc/bcaslot.hxx6
3 files changed, 32 insertions, 5 deletions
diff --git a/sc/inc/scopetools.hxx b/sc/inc/scopetools.hxx
index 571b1fce52f5..b71154330e96 100644
--- a/sc/inc/scopetools.hxx
+++ b/sc/inc/scopetools.hxx
@@ -24,6 +24,12 @@ class SC_DLLPUBLIC AutoCalcSwitch
{
ScDocument& mrDoc;
bool const mbOldValue;
+
+ AutoCalcSwitch(AutoCalcSwitch const &) = delete;
+ AutoCalcSwitch(AutoCalcSwitch &&) = delete;
+ AutoCalcSwitch & operator =(AutoCalcSwitch const &) = delete;
+ AutoCalcSwitch & operator =(AutoCalcSwitch &&) = delete;
+
public:
AutoCalcSwitch(ScDocument& rDoc, bool bAutoCalc);
~AutoCalcSwitch();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3c34473359f2..fa1913a0c11c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1226,8 +1226,11 @@ struct BroadcastRecalcOnRefMoveHandler
if (p)
p->BroadcastRecalcOnRefMove();
}
+};
- explicit BroadcastRecalcOnRefMoveHandler( ScDocument* pDoc ) :
+struct BroadcastRecalcOnRefMoveGuard
+{
+ explicit BroadcastRecalcOnRefMoveGuard( ScDocument* pDoc ) :
aSwitch( *pDoc, false),
aBulk( pDoc->GetBASM(), SfxHintId::ScDataChanged)
{
@@ -1339,7 +1342,10 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
a->SetDirtyIfPostponed();
}
- std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
+ {
+ BroadcastRecalcOnRefMoveGuard g(this);
+ std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
+ }
}
bRet = true;
}
@@ -1450,7 +1456,10 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
a->SetDirtyIfPostponed();
}
- std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
+ {
+ BroadcastRecalcOnRefMoveGuard g(this);
+ std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
+ }
}
if (pChartListenerCollection)
@@ -1552,7 +1561,10 @@ bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
std::for_each(maTabs.begin(), maTabs.end(), SetDirtyIfPostponedHandler());
// Cells containing functions such as CELL, COLUMN or ROW may have
// changed their values on relocation. Broadcast them.
- std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
+ {
+ BroadcastRecalcOnRefMoveGuard g(this);
+ std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
+ }
}
bRet = true;
}
@@ -1653,7 +1665,10 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
a->SetDirtyIfPostponed();
}
- std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
+ {
+ BroadcastRecalcOnRefMoveGuard g(this);
+ std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
+ }
}
if (pChartListenerCollection)
diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx
index 20322d5f4fc2..11c0942df9a2 100644
--- a/sc/source/core/inc/bcaslot.hxx
+++ b/sc/source/core/inc/bcaslot.hxx
@@ -351,6 +351,12 @@ class ScBulkBroadcast
{
ScBroadcastAreaSlotMachine* pBASM;
SfxHintId const mnHintId;
+
+ ScBulkBroadcast(ScBulkBroadcast const &) = delete;
+ ScBulkBroadcast(ScBulkBroadcast &&) = delete;
+ ScBulkBroadcast & operator =(ScBulkBroadcast const &) = delete;
+ ScBulkBroadcast & operator =(ScBulkBroadcast &&) = delete;
+
public:
explicit ScBulkBroadcast( ScBroadcastAreaSlotMachine* p, SfxHintId nHintId ) :
pBASM(p),