summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-05-10 12:51:46 +0200
committerMichael Stahl <mstahl@redhat.com>2016-05-11 12:54:21 +0000
commitea0951bcc0d66db288e4723e3147a04ef47eca50 (patch)
tree276a75a3b507bf249aef51b9faecb55c1cc907ce /svx
parent27db0b033235bb5379b5af4f530413750bee9f29 (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. Reviewed-on: https://gerrit.libreoffice.org/24305 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de> (cherry picked from commit e6adb3e8b4de3c0f78d249b83de19b849ef65b59) Change-Id: If9b37d341fcfa4e65485c54054d47964ee2fff5f Reviewed-on: https://gerrit.libreoffice.org/24843 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
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 03572fc29389..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 );
- 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 a500958a86b8..4f5ca08484e9 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1969,9 +1969,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 26e18ae690f6..60c6a49e450b 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1842,8 +1842,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;