Kaydet (Commit) 3a34f96a authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#91416 setting progress -> resize -> destroy formula context

i.e. setting progress triggers ScTabView::DoResize and an InterpretVisible and
InterpretDirtyCells which resets the mpFormulaGroupCxt that the current rCxt
points to, which is bad, so disable progress for the duration of the GetResult
loop

Change-Id: I8e88cee4dd2308ef61dee934d300a38978833703
(cherry picked from commit e3c1a394)
üst 813faac4
...@@ -49,6 +49,7 @@ private: ...@@ -49,6 +49,7 @@ private:
static bool bAllowInterpretProgress; static bool bAllowInterpretProgress;
static ScDocument* pInterpretDoc; static ScDocument* pInterpretDoc;
static bool bIdleWasEnabled; static bool bIdleWasEnabled;
bool bEnabled;
SfxProgress* pProgress; SfxProgress* pProgress;
...@@ -143,6 +144,9 @@ public: ...@@ -143,6 +144,9 @@ public:
return pProgress->GetState(); return pProgress->GetState();
return 0; return 0;
} }
bool Enabled() const { return bEnabled; }
void Disable() { bEnabled = false; }
void Enable() { bEnabled = true; }
}; };
#endif #endif
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "formulagroup.hxx" #include "formulagroup.hxx"
#include "listenercontext.hxx" #include "listenercontext.hxx"
#include "mtvcellfunc.hxx" #include "mtvcellfunc.hxx"
#include "progress.hxx"
#include "scmatrix.hxx" #include "scmatrix.hxx"
#include <rowheightcontext.hxx> #include <rowheightcontext.hxx>
...@@ -2306,10 +2307,23 @@ bool appendToBlock( ...@@ -2306,10 +2307,23 @@ bool appendToBlock(
sc::formula_block::iterator itData, itDataEnd; sc::formula_block::iterator itData, itDataEnd;
getBlockIterators<sc::formula_block>(it, nLenRemain, itData, itDataEnd); getBlockIterators<sc::formula_block>(it, nLenRemain, itData, itDataEnd);
/* tdf#91416 setting progress in triggers a resize of the window
and so ScTabView::DoResize and an InterpretVisible and
InterpretDirtyCells which resets the mpFormulaGroupCxt that
the current rCxt points to, which is bad, so disable progress
during GetResult
*/
ScProgress *pProgress = ScProgress::GetInterpretProgress();
bool bTempDisableProgress = pProgress && pProgress->Enabled();
if (bTempDisableProgress)
pProgress->Disable();
for (; itData != itDataEnd; ++itData, ++nPos) for (; itData != itDataEnd; ++itData, ++nPos)
{ {
ScFormulaCell& rFC = **itData; ScFormulaCell& rFC = **itData;
sc::FormulaResultValue aRes = rFC.GetResult(); sc::FormulaResultValue aRes = rFC.GetResult();
if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError) if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError)
{ {
if (aRes.mnError == ScErrorCodes::errCircularReference) if (aRes.mnError == ScErrorCodes::errCircularReference)
...@@ -2332,6 +2346,9 @@ bool appendToBlock( ...@@ -2332,6 +2346,9 @@ bool appendToBlock(
(*rColArray.mpNumArray)[nPos] = aRes.mfValue; (*rColArray.mpNumArray)[nPos] = aRes.mfValue;
} }
} }
if (bTempDisableProgress)
pProgress->Enable();
} }
break; break;
case sc::element_type_empty: case sc::element_type_empty:
......
...@@ -1931,8 +1931,12 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) ...@@ -1931,8 +1931,12 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
} }
// Reschedule slows the whole thing down considerably, thus only execute on percent change // Reschedule slows the whole thing down considerably, thus only execute on percent change
ScProgress::GetInterpretProgress()->SetStateCountDownOnPercent( ScProgress *pProgress = ScProgress::GetInterpretProgress();
pDocument->GetFormulaCodeInTree()/MIN_NO_CODES_PER_PROGRESS_UPDATE ); if (pProgress && pProgress->Enabled())
{
pProgress->SetStateCountDownOnPercent(
pDocument->GetFormulaCodeInTree()/MIN_NO_CODES_PER_PROGRESS_UPDATE );
}
switch (p->GetVolatileType()) switch (p->GetVolatileType())
{ {
......
...@@ -70,8 +70,9 @@ static bool lcl_HasControllersLocked( SfxObjectShell& rObjSh ) ...@@ -70,8 +70,9 @@ static bool lcl_HasControllersLocked( SfxObjectShell& rObjSh )
return false; return false;
} }
ScProgress::ScProgress( SfxObjectShell* pObjSh, const OUString& rText, ScProgress::ScProgress(SfxObjectShell* pObjSh, const OUString& rText,
sal_uLong nRange, bool bAllDocs, bool bWait ) sal_uLong nRange, bool bAllDocs, bool bWait)
: bEnabled(true)
{ {
if ( pGlobalProgress || SfxProgress::GetActiveProgress( NULL ) ) if ( pGlobalProgress || SfxProgress::GetActiveProgress( NULL ) )
...@@ -114,9 +115,11 @@ ScProgress::ScProgress( SfxObjectShell* pObjSh, const OUString& rText, ...@@ -114,9 +115,11 @@ ScProgress::ScProgress( SfxObjectShell* pObjSh, const OUString& rText,
} }
} }
ScProgress::ScProgress() : ScProgress::ScProgress()
pProgress( NULL ) : bEnabled(true)
{ // DummyInterpret , pProgress(NULL)
{
// DummyInterpret
} }
ScProgress::~ScProgress() ScProgress::~ScProgress()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment