summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-04-22 17:54:14 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-04-26 10:34:04 +0000
commite6adb3e8b4de3c0f78d249b83de19b849ef65b59 (patch)
treeb9db8d5a0dbb002cceef69180106828df7849dca /svx
parented42a984099b8847aedbdd638c7e20e0b68a9290 (diff)
tdf#98163 Flush ressources at CustomShapes during import
During ODF import using API for CustomShapes Outliners and VirtualDevioces get created and not destroyed due to referencing. This makes the ressources blow up, even under 64bit windows. Also see tdf#93994 where this was already fixed on page base, but this is not sufficient for this case. Change-Id: If9b37d341fcfa4e65485c54054d47964ee2fff5f Reviewed-on: https://gerrit.libreoffice.org/24305 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/inc/svdoutlinercache.hxx15
-rw-r--r--svx/source/svdraw/svdmodel.cxx4
-rw-r--r--svx/source/svdraw/svdoutlinercache.cxx47
-rw-r--r--svx/source/unodraw/unoshap2.cxx18
4 files changed, 52 insertions, 32 deletions
diff --git a/svx/source/inc/svdoutlinercache.hxx b/svx/source/inc/svdoutlinercache.hxx
index 39bb5d85ce3c..3bc3212b94d5 100644
--- a/svx/source/inc/svdoutlinercache.hxx
+++ b/svx/source/inc/svdoutlinercache.hxx
@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <vector>
+#include <set>
class SdrModel;
class SdrOutliner;
@@ -30,22 +31,18 @@ class SdrOutliner;
class SdrOutlinerCache
{
private:
- SdrModel* mpModel;
+ SdrModel* mpModel;
+ std::vector< SdrOutliner* > maModeOutline;
+ std::vector< SdrOutliner* > maModeText;
+ std::set< SdrOutliner* > maActiveOutliners;
- SdrOutliner* mpModeOutline;
- SdrOutliner* mpModeText;
-
- std::vector<SdrOutliner*> maActiveOutliners;
public:
SdrOutlinerCache( SdrModel* pModel );
~SdrOutlinerCache();
SdrOutliner* createOutliner( sal_uInt16 nOutlinerMode );
void disposeOutliner( SdrOutliner* pOutliner );
- const std::vector<SdrOutliner*>& GetActiveOutliners() const
- {
- return maActiveOutliners;
- }
+ std::vector< SdrOutliner* > GetActiveOutliners() const;
};
#endif
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index ffa16dc62dc5..4aea8c6f78ae 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1963,9 +1963,7 @@ SdrOutliner* SdrModel::createOutliner( sal_uInt16 nOutlinerMode )
std::vector<SdrOutliner*> SdrModel::GetActiveOutliners() const
{
- std::vector<SdrOutliner*> aRet(mpOutlinerCache ?
- mpOutlinerCache->GetActiveOutliners() : std::vector<SdrOutliner*>());
-
+ std::vector< SdrOutliner* > aRet(mpOutlinerCache ? mpOutlinerCache->GetActiveOutliners() : std::vector< SdrOutliner* >());
aRet.push_back(pDrawOutliner);
aRet.push_back(pHitTestOutliner);
diff --git a/svx/source/svdraw/svdoutlinercache.cxx b/svx/source/svdraw/svdoutlinercache.cxx
index c9e9beeb699d..72e0069d8691 100644
--- a/svx/source/svdraw/svdoutlinercache.cxx
+++ b/svx/source/svdraw/svdoutlinercache.cxx
@@ -24,8 +24,9 @@
SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
: mpModel( pModel ),
- mpModeOutline( nullptr ),
- mpModeText( nullptr )
+ maModeOutline(),
+ maModeText(),
+ maActiveOutliners()
{
}
@@ -33,22 +34,22 @@ SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
{
SdrOutliner* pOutliner = nullptr;
- if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
+ if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && !maModeOutline.empty() )
{
- pOutliner = mpModeOutline;
- mpModeOutline = nullptr;
+ pOutliner = maModeOutline.back();
+ maModeOutline.pop_back();
}
- else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
+ else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && !maModeText.empty() )
{
- pOutliner = mpModeText;
- mpModeText = nullptr;
+ pOutliner = maModeText.back();
+ maModeText.pop_back();
}
else
{
pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel);
Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
- maActiveOutliners.push_back(pOutliner);
+ maActiveOutliners.insert(pOutliner);
}
return pOutliner;
@@ -56,17 +57,19 @@ SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
SdrOutlinerCache::~SdrOutlinerCache()
{
- if( mpModeOutline )
+ for( auto candA : maModeOutline )
{
- delete mpModeOutline;
- mpModeOutline = nullptr;
+ delete candA;
}
- if( mpModeText )
+ maModeOutline.clear();
+
+ for( auto candB : maModeText )
{
- delete mpModeText;
- mpModeText = nullptr;
+ delete candB;
}
+
+ maModeText.clear();
}
void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
@@ -75,18 +78,18 @@ void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
{
sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
- if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (nullptr == mpModeOutline) )
+ if( OUTLINERMODE_OUTLINEOBJECT == nOutlMode )
{
- mpModeOutline = pOutliner;
+ maModeOutline.push_back(pOutliner);
pOutliner->Clear();
pOutliner->SetVertical( false );
// Deregister on outliner, might be reused from outliner cache
pOutliner->SetNotifyHdl( Link<EENotify&,void>() );
}
- else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (nullptr == mpModeText) )
+ else if( OUTLINERMODE_TEXTOBJECT == nOutlMode )
{
- mpModeText = pOutliner;
+ maModeText.push_back(pOutliner);
pOutliner->Clear();
pOutliner->SetVertical( false );
@@ -95,11 +98,15 @@ void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
}
else
{
- maActiveOutliners.erase(std::remove(maActiveOutliners.begin(), maActiveOutliners.end(), pOutliner), maActiveOutliners.end());
+ maActiveOutliners.erase(pOutliner);
delete pOutliner;
}
}
}
+std::vector< SdrOutliner* > SdrOutlinerCache::GetActiveOutliners() const
+{
+ return std::vector< SdrOutliner* >(maActiveOutliners.begin(), maActiveOutliners.end());
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index e0dffd8a4de4..246ec629ab38 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1822,8 +1822,26 @@ void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, c
throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, std::exception)
{
::SolarMutexGuard aGuard;
+
SdrObject* pObject = mpObj.get();
+ // tdf#98163 Use a custom slot to have filter code flush the UNO
+ // API implementations of SdrObjCustomShape. Used e.g. by
+ // ~SdXMLCustomShapeContext, see there for more information
+ const OUString sFlushCustomShapeUnoApiObjects("FlushCustomShapeUnoApiObjects");
+ if(sFlushCustomShapeUnoApiObjects == aPropertyName)
+ {
+ SdrObjCustomShape* pTarget = dynamic_cast< SdrObjCustomShape* >(pObject);
+ if(pTarget)
+ {
+ // Luckily, the object causing problems in tdf#93994 is not the
+ // UNO API object, but the XCustomShapeEngine involved. This
+ // object is on-demand replacable and can be reset here. This
+ // will free the involved EditEngine and VirtualDevice.
+ pTarget->mxCustomShapeEngine.set(nullptr);
+ }
+ }
+
bool bCustomShapeGeometry = pObject && aPropertyName == "CustomShapeGeometry";
bool bMirroredX = false;