diff options
author | Martijn Kaijser <martijn@xbmc.org> | 2016-09-17 13:34:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-17 13:34:04 +0200 |
commit | 2ac599b2143b24750a4d45ae4010b069fe7d47e0 (patch) | |
tree | c27c17b9bf103397bd3e24cdf60c9371028de29a | |
parent | 56423ffa3a89d5750a053cd55a6fd36221176f7f (diff) | |
parent | 1f9aa00f67ec7e72044289bdf9d9ef01d606090e (diff) |
Merge pull request #10476 from tamland/fix_settings_initialization
maybe fix android crash after #10335
-rw-r--r-- | xbmc/addons/AddonSystemSettings.cpp | 44 | ||||
-rw-r--r-- | xbmc/addons/AddonSystemSettings.h | 4 |
2 files changed, 26 insertions, 22 deletions
diff --git a/xbmc/addons/AddonSystemSettings.cpp b/xbmc/addons/AddonSystemSettings.cpp index fccc680bd1..6df9d33b35 100644 --- a/xbmc/addons/AddonSystemSettings.cpp +++ b/xbmc/addons/AddonSystemSettings.cpp @@ -31,6 +31,23 @@ namespace ADDON { +CAddonSystemSettings::CAddonSystemSettings() : + m_activeSettings{ + {ADDON_VIZ, CSettings::SETTING_MUSICPLAYER_VISUALISATION}, + {ADDON_SCREENSAVER, CSettings::SETTING_SCREENSAVER_MODE}, + {ADDON_SCRAPER_ALBUMS, CSettings::SETTING_MUSICLIBRARY_ALBUMSSCRAPER}, + {ADDON_SCRAPER_ARTISTS, CSettings::SETTING_MUSICLIBRARY_ARTISTSSCRAPER}, + {ADDON_SCRAPER_MOVIES, CSettings::SETTING_SCRAPERS_MOVIESDEFAULT}, + {ADDON_SCRAPER_MUSICVIDEOS, CSettings::SETTING_SCRAPERS_MUSICVIDEOSDEFAULT}, + {ADDON_SCRAPER_TVSHOWS, CSettings::SETTING_SCRAPERS_TVSHOWSDEFAULT}, + {ADDON_WEB_INTERFACE, CSettings::SETTING_SERVICES_WEBSKIN}, + {ADDON_RESOURCE_LANGUAGE, CSettings::SETTING_LOCALE_LANGUAGE}, + {ADDON_SCRIPT_WEATHER, CSettings::SETTING_WEATHER_ADDON}, + {ADDON_SKIN, CSettings::SETTING_LOOKANDFEEL_SKIN}, + {ADDON_RESOURCE_UISOUNDS, CSettings::SETTING_LOOKANDFEEL_SOUNDSKIN}, + } +{} + CAddonSystemSettings& CAddonSystemSettings::GetInstance() { static CAddonSystemSettings inst; @@ -63,25 +80,10 @@ void CAddonSystemSettings::OnSettingChanged(const CSetting* setting) } } -static const std::map<ADDON::TYPE, std::string> settingMap = { - {ADDON_VIZ, CSettings::SETTING_MUSICPLAYER_VISUALISATION}, - {ADDON_SCREENSAVER, CSettings::SETTING_SCREENSAVER_MODE}, - {ADDON_SCRAPER_ALBUMS, CSettings::SETTING_MUSICLIBRARY_ALBUMSSCRAPER}, - {ADDON_SCRAPER_ARTISTS, CSettings::SETTING_MUSICLIBRARY_ARTISTSSCRAPER}, - {ADDON_SCRAPER_MOVIES, CSettings::SETTING_SCRAPERS_MOVIESDEFAULT}, - {ADDON_SCRAPER_MUSICVIDEOS, CSettings::SETTING_SCRAPERS_MUSICVIDEOSDEFAULT}, - {ADDON_SCRAPER_TVSHOWS, CSettings::SETTING_SCRAPERS_TVSHOWSDEFAULT}, - {ADDON_WEB_INTERFACE, CSettings::SETTING_SERVICES_WEBSKIN}, - {ADDON_RESOURCE_LANGUAGE, CSettings::SETTING_LOCALE_LANGUAGE}, - {ADDON_SCRIPT_WEATHER, CSettings::SETTING_WEATHER_ADDON}, - {ADDON_SKIN, CSettings::SETTING_LOOKANDFEEL_SKIN}, - {ADDON_RESOURCE_UISOUNDS, CSettings::SETTING_LOOKANDFEEL_SOUNDSKIN}, -}; - bool CAddonSystemSettings::GetActive(const TYPE& type, AddonPtr& addon) { - auto it = settingMap.find(type); - if (it != settingMap.end()) + auto it = m_activeSettings.find(type); + if (it != m_activeSettings.end()) { auto settingValue = CSettings::GetInstance().GetString(it->second); return CAddonMgr::GetInstance().GetAddon(settingValue, addon, type); @@ -91,8 +93,8 @@ bool CAddonSystemSettings::GetActive(const TYPE& type, AddonPtr& addon) bool CAddonSystemSettings::SetActive(const TYPE& type, const std::string& addonID) { - auto it = settingMap.find(type); - if (it != settingMap.end()) + auto it = m_activeSettings.find(type); + if (it != m_activeSettings.end()) { CSettings::GetInstance().SetString(it->second, addonID); return true; @@ -108,8 +110,8 @@ bool CAddonSystemSettings::IsActive(const IAddon& addon) bool CAddonSystemSettings::UnsetActive(const AddonPtr& addon) { - auto it = settingMap.find(addon->Type()); - if (it == settingMap.end()) + auto it = m_activeSettings.find(addon->Type()); + if (it == m_activeSettings.end()) return true; auto setting = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(it->second)); diff --git a/xbmc/addons/AddonSystemSettings.h b/xbmc/addons/AddonSystemSettings.h index 42a5345aad..f23c9eb119 100644 --- a/xbmc/addons/AddonSystemSettings.h +++ b/xbmc/addons/AddonSystemSettings.h @@ -53,11 +53,13 @@ public: std::vector<std::string> MigrateAddons(); private: - CAddonSystemSettings() = default; + CAddonSystemSettings(); CAddonSystemSettings(const CAddonSystemSettings&) = default; CAddonSystemSettings& operator=(const CAddonSystemSettings&) = default; CAddonSystemSettings(CAddonSystemSettings&&); CAddonSystemSettings& operator=(CAddonSystemSettings&&); virtual ~CAddonSystemSettings() = default; + + const std::map<ADDON::TYPE, std::string> m_activeSettings; }; };
\ No newline at end of file |