summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-01-28 20:48:01 -0500
committerAndras Timar <andras.timar@collabora.com>2019-03-04 15:22:24 +0100
commitda70e562087b6016aeaffadedc4ce66eaf370919 (patch)
treefd591852e6ceb2a120eccb833838ed8e658eb656 /sd
parent312346531dde33cd000a1d3c95c7b7829b656438 (diff)
sd: LOK: avoid caching pointers and leaking
Change-Id: I68163bc30b0655b11dec34bdcc750b495b93365a Reviewed-on: https://gerrit.libreoffice.org/68265 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/CustomAnimationPreset.hxx2
-rw-r--r--sd/source/core/CustomAnimationPreset.cxx19
2 files changed, 9 insertions, 12 deletions
diff --git a/sd/inc/CustomAnimationPreset.hxx b/sd/inc/CustomAnimationPreset.hxx
index 790569613d82..5209e8c35d1c 100644
--- a/sd/inc/CustomAnimationPreset.hxx
+++ b/sd/inc/CustomAnimationPreset.hxx
@@ -128,7 +128,7 @@ private:
PresetCategoryList maMiscPresets;
//! Maps per-language the animation presets.
- SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets*> mpCustomAnimationPresetsMap;
+ SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets> mPresetsMap;
};
diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index 6d2f44ccba4c..c4be1dd032f6 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -529,7 +529,7 @@ void CustomAnimationPresets::changePresetSubType( const CustomAnimationEffectPtr
}
}
-std::map<OUString, CustomAnimationPresets*> CustomAnimationPresets::mpCustomAnimationPresetsMap;
+std::map<OUString, CustomAnimationPresets> CustomAnimationPresets::mPresetsMap;
const CustomAnimationPresets& CustomAnimationPresets::getCustomAnimationPresets()
{
@@ -540,16 +540,13 @@ const CustomAnimationPresets& CustomAnimationPresets::getCustomAnimationPresets(
: SvtSysLocaleOptions().GetLanguageTag().getLanguage();
SolarMutexGuard aGuard;
- const auto it = mpCustomAnimationPresetsMap.find(aLang);
- if (it != mpCustomAnimationPresetsMap.end())
- return *it->second;
-
- // Note: we are invoked recursively(!), so we must set the instance pointer
- // in the cache map before we importResources, lest we get in infinite loop.
- sd::CustomAnimationPresets* pCustomAnimationPresets = new sd::CustomAnimationPresets();
- mpCustomAnimationPresetsMap[aLang] = pCustomAnimationPresets;
- pCustomAnimationPresets->importResources();
- return *pCustomAnimationPresets;
+ const auto it = mPresetsMap.find(aLang);
+ if (it != mPresetsMap.end())
+ return it->second;
+
+ CustomAnimationPresets& rPresets = mPresetsMap[aLang];
+ rPresets.importResources();
+ return rPresets;
}
Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 nPresetClass ) const