summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/ole/ndole.cxx44
1 files changed, 36 insertions, 8 deletions
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index 380a0b87c8c4..3b7b779294c3 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -643,8 +643,36 @@ bool SwOLENode::IsChart() const
return bIsChart;
}
-//////////////////////////////////////////////////////////////////////////////
+// due to some problems in test cases with the SharedOptimalPool, use
+// an own instance of comphelper::ThreadPool. Problem is that other
+// usages of getSharedOptimalPool() may interfere if more than one
+// pool user calls waitUntilEmpty().
+//
+// It gets created on-demand and will be available during LO's
+// lifetime for loading chart models used in writer in parallel. It
+// would be possible to add a usage count, then trigger a timer and
+// clean it up (due to lifetime issues), but that's probably overkill.
+// It gets created on demand, is ready for global reuse and makes no
+// harm (not much ressources needed)
+static comphelper::ThreadPool* pLocalPool = 0;
+
+comphelper::ThreadPool* getLocalThreadPool()
+{
+ if (pLocalPool)
+ {
+ return pLocalPool;
+ }
+ if (0 == comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount())
+ {
+ return nullptr;
+ }
+
+ pLocalPool = new comphelper::ThreadPool(comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount());
+ return pLocalPool;
+}
+
+/// Holder for local data for a parallely-executed task to load a chart model
class DeflateData
{
private:
@@ -702,8 +730,7 @@ public:
}
};
-//////////////////////////////////////////////////////////////////////////////
-
+/// Task for parallely-executed task to load a chart model
class DeflateThread : public comphelper::ThreadTask
{
// the data to work on
@@ -1048,13 +1075,14 @@ drawinglayer::primitive2d::Primitive2DContainer SwOLEObj::tryToGetChartContentAs
if(aXModel.is())
{
- // due to some problems in test cases with the SharedOptimalPool,
- // I need to deactivate this for now
- static bool bAnynchronousLoadingAllowed = false;
+ // loaded using own instance of comphelper::ThreadPool,
+ // see getLocalThreadPool(). Disable via bool below if
+ // trouble surfaces somewhere
+ static bool bAnynchronousLoadingAllowed = true;
if(bSynchron ||
!bAnynchronousLoadingAllowed ||
- 0 == comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount())
+ nullptr == getLocalThreadPool())
{
// load chart synchron in this Thread
m_aPrimitive2DSequence = ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
@@ -1070,7 +1098,7 @@ drawinglayer::primitive2d::Primitive2DContainer SwOLEObj::tryToGetChartContentAs
{
m_pDeflateData = new DeflateData(aXModel);
DeflateThread* pNew = new DeflateThread(*m_pDeflateData);
- comphelper::ThreadPool::getSharedOptimalPool().pushTask(pNew);
+ getLocalThreadPool()->pushTask(pNew);
}
}
}