diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-02-25 15:45:43 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-03-04 15:23:36 +0100 |
commit | 233c9a12fd578e9a518cf6841d186f2f884d594d (patch) | |
tree | ba7eafd11ccf38c50b6b0190439865d9315f5fc2 /sc/inc | |
parent | 7b9e13376423d54cf95dfc48c9d3de0a62826943 (diff) |
do not call GetFormatTable() from GetNonThreadedContext() (tdf#121949)
ScDocument dtor calls ClearLookupCaches(), which calls GetNonThreadedContext().
But ScDocument instances used for copy&paste GetFormatTable() fails
on null mxPoolHelper, because ScDocument ctor doesn't set it in such a case.
So set up the pointer in ScInterpreterContext on demand only if actually
needed.
Change-Id: If3811da5bb00a2d7d404c089ee1bf46037a2cddb
Reviewed-on: https://gerrit.libreoffice.org/68350
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
(cherry picked from commit b5c3f38cb8d4121e3303be362e0757d3d3431059)
Reviewed-on: https://gerrit.libreoffice.org/68539
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/document.hxx | 3 | ||||
-rw-r--r-- | sc/inc/global.hxx | 2 | ||||
-rw-r--r-- | sc/inc/interpretercontext.hxx | 12 |
3 files changed, 11 insertions, 6 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 6a584b47d0a8..3fbe9cd899d5 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -582,8 +582,7 @@ public: ScInterpreterContext& GetNonThreadedContext() const { - // GetFormatTable() asserts that we are not in a threaded calculation - maInterpreterContext.mpFormatter = GetFormatTable(); + assert(!IsThreadedGroupCalcInProgress()); return maInterpreterContext; } // Uses thread_local. diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index e6a33de7830b..176cfe124518 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -809,7 +809,7 @@ public: SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType ); /// Calc's threaded group calculation is in progress. - static bool bThreadedGroupCalcInProgress; + SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress; }; // maybe move to dbdata.hxx (?): diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx index 2f3e33040702..9fb2bc3993c5 100644 --- a/sc/inc/interpretercontext.hxx +++ b/sc/inc/interpretercontext.hxx @@ -37,7 +37,6 @@ class ScInterpreterContextPool; struct ScInterpreterContext { const ScDocument* mpDoc; - SvNumberFormatter* mpFormatter; size_t mnTokenCachePos; std::vector<formula::FormulaToken*> maTokens; std::vector<DelayedSetNumberFormat> maDelayedSetNumberFormat; @@ -48,10 +47,10 @@ struct ScInterpreterContext ScInterpreterContext(const ScDocument& rDoc, SvNumberFormatter* pFormatter) : mpDoc(&rDoc) - , mpFormatter(pFormatter) , mnTokenCachePos(0) , maTokens(TOKEN_CACHE_SIZE, nullptr) , mScLookupCache(nullptr) + , mpFormatter(pFormatter) { } @@ -59,7 +58,12 @@ struct ScInterpreterContext ~ScInterpreterContext(); - SvNumberFormatter* GetFormatTable() const { return mpFormatter; } + SvNumberFormatter* GetFormatTable() const + { + if (mpFormatter == nullptr) + const_cast<ScInterpreterContext*>(this)->initFormatTable(); + return mpFormatter; + } private: friend class ScInterpreterContextPool; @@ -67,6 +71,8 @@ private: void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* pFormatter); void Cleanup(); void ClearLookupCache(); + void initFormatTable(); + SvNumberFormatter* mpFormatter; }; class ScThreadedInterpreterContextGetterGuard; |