[Libreoffice-commits] core.git: compilerplugins/clang sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 15:06:23 UTC 2018
compilerplugins/clang/badstatics.cxx | 2 ++
sc/inc/document.hxx | 11 +++++++++--
sc/source/core/data/documen8.cxx | 2 ++
sc/source/ui/unoobj/docuno.cxx | 3 ++-
4 files changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 2dbda86cca1301b81a4232a6f0c03559da5ed7f4
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 7 16:01:30 2018 +0100
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Nov 14 16:05:55 2018 +0100
make ScInterpreterContext also accessible without passing it around
E.g. ScModelObj::GetFormatter() can be rather deep in the call chain
and it just doesn't make sense to pass ScInterpreterContext* to
all the relevant places (and it's a question if it makes sense
to pass it around at all, googling shows that thread_local is not
really _that_ slow).
Change-Id: I9114ef8a10d82a10968391718099edccde7a2663
Reviewed-on: https://gerrit.libreoffice.org/63184
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 43c26558ccbc..39b99e6de71e 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -197,6 +197,8 @@ public:
|| name == "m_aUncommitedRegistrations" // sw/source/uibase/dbui/dbmgr.cxx
|| (loplugin::DeclCheck(pVarDecl).Var("aAllListeners")
.Class("ScAddInListener").GlobalNamespace()) // not owning
+ || (loplugin::DeclCheck(pVarDecl).Var("maThreadSpecific")
+ .Class("ScDocument").GlobalNamespace()) // not owning
|| name == "s_pLOKWindowsMap" // LOK only, guarded by assert, and LOK never tries to perform a VCL cleanup
|| name == "gStaticManager" // vcl/source/graphic/Manager.cxx - stores non-owning pointers
) // these variables appear unproblematic
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6fe442954901..22ce96e010ef 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -275,9 +275,11 @@ const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink()
struct ScDocumentThreadSpecific
{
ScRecursionHelper* pRecursionHelper; // information for recursive and iterative cell formulas
+ ScInterpreterContext* pContext; // references the context passed around for easier access
- ScDocumentThreadSpecific() :
- pRecursionHelper(nullptr)
+ ScDocumentThreadSpecific()
+ : pRecursionHelper(nullptr)
+ , pContext(nullptr)
{
}
@@ -582,6 +584,11 @@ public:
maInterpreterContext.mpFormatter = GetFormatTable();
return maInterpreterContext;
}
+ // Uses thread_local.
+ ScInterpreterContext& GetThreadedContext() const
+ {
+ return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
+ }
void SetupFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
void MergeBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 84df9ff48195..943be7200a68 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -415,10 +415,12 @@ const ScDocumentThreadSpecific& ScDocument::CalculateInColumnInThread( ScInterpr
assert(IsThreadedGroupCalcInProgress());
+ maThreadSpecific.pContext = &rContext;
maThreadSpecific.SetupFromNonThreadedData(maNonThreaded);
pTab->CalculateInColumnInThread(rContext, rTopPos.Col(), rTopPos.Row(), nLen, nThisThread, nThreadsTotal);
assert(IsThreadedGroupCalcInProgress());
+ maThreadSpecific.pContext = nullptr;
return maThreadSpecific;
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 255e1a4ef3f4..22d75e24c58c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -425,7 +425,8 @@ uno::Reference< uno::XAggregation> const & ScModelObj::GetFormatter()
osl_atomic_increment( &m_refCount );
// we need a reference to SvNumberFormatsSupplierObj during queryInterface,
// otherwise it'll be deleted
- uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj(pDocShell->GetDocument().GetFormatTable() ));
+ uno::Reference<util::XNumberFormatsSupplier> xFormatter(
+ new SvNumberFormatsSupplierObj(pDocShell->GetDocument().GetThreadedContext().GetFormatTable() ));
{
xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY ));
// extra block to force deletion of the temporary before setDelegator
More information about the Libreoffice-commits
mailing list