Kaydet (Commit) da70e562 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Andras Timar

sd: LOK: avoid caching pointers and leaking

Change-Id: I68163bc30b0655b11dec34bdcc750b495b93365a
Reviewed-on: https://gerrit.libreoffice.org/68265Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 31234653
......@@ -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;
};
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment