From b5c3f38cb8d4121e3303be362e0757d3d3431059 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Mon, 25 Feb 2019 15:45:43 +0100 Subject: 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 --- sc/source/core/data/table3.cxx | 4 ++-- sc/source/core/tool/interpretercontext.cxx | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 055c55fc14ba..4e9f074470ae 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2360,7 +2360,7 @@ public: { sal_uInt32 nNumFmt = pContext ? mrTab.GetNumberFormat(*pContext, ScAddress(nCol, nRow, mrTab.GetTab())) : mrTab.GetNumberFormat(nCol, nRow); - SvNumberFormatter* pFormatter = pContext ? pContext->mpFormatter : mrDoc.GetFormatTable(); + SvNumberFormatter* pFormatter = pContext ? pContext->GetFormatTable() : mrDoc.GetFormatTable(); const SvNumberformat* pEntry = pFormatter->GetEntry(nNumFmt); if (pEntry) { @@ -2434,7 +2434,7 @@ public: sal_uInt32 nFormat = pContext ? mrTab.GetNumberFormat( *pContext, ScAddress(static_cast(rEntry.nField), nRow, mrTab.GetTab()) ) : mrTab.GetNumberFormat( static_cast(rEntry.nField), nRow ); OUString aStr; - SvNumberFormatter* pFormatter = pContext ? pContext->mpFormatter : mrDoc.GetFormatTable(); + SvNumberFormatter* pFormatter = pContext ? pContext->GetFormatTable() : mrDoc.GetFormatTable(); ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, &mrDoc); return compareByStringComparator(rEntry, rItem, nullptr, &aStr); } diff --git a/sc/source/core/tool/interpretercontext.cxx b/sc/source/core/tool/interpretercontext.cxx index bc67afca039c..b997effe13c4 100644 --- a/sc/source/core/tool/interpretercontext.cxx +++ b/sc/source/core/tool/interpretercontext.cxx @@ -18,6 +18,8 @@ */ #include + +#include #include #include #include @@ -47,6 +49,11 @@ void ScInterpreterContext::SetDocAndFormatter(const ScDocument& rDoc, SvNumberFo mpFormatter = pFormatter; } +void ScInterpreterContext::initFormatTable() +{ + mpFormatter = mpDoc->GetFormatTable(); // will assert if not main thread +} + void ScInterpreterContext::Cleanup() { // Do not disturb mScLookupCache -- cgit