From 3ead79cb650a51da3080d273cea701578cb23827 Mon Sep 17 00:00:00 2001 From: enen92 <92enen@gmail.com> Date: Fri, 7 Dec 2018 16:48:53 +0000 Subject: [settings] Fix regression (setting reuse) --- xbmc/addons/settings/AddonSettings.cpp | 21 ++++++++++++--------- xbmc/addons/settings/AddonSettings.h | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/xbmc/addons/settings/AddonSettings.cpp b/xbmc/addons/settings/AddonSettings.cpp index caaa117912..20c3b611f9 100644 --- a/xbmc/addons/settings/AddonSettings.cpp +++ b/xbmc/addons/settings/AddonSettings.cpp @@ -430,11 +430,10 @@ bool CAddonSettings::ParseSettingVersion(const CXBMCTinyXML& doc, uint32_t& vers return true; } -std::shared_ptr CAddonSettings::ParseOldSettingElement(const TiXmlElement* categoryElement, std::shared_ptr category, std::set& actionSettings) +std::shared_ptr CAddonSettings::ParseOldSettingElement(const TiXmlElement* categoryElement, std::shared_ptr category, std::set& actionSettings, std::set& settingIds) { // build a vector of settings from the same category std::vector> categorySettings; - std::set settingIds; // prepare for settings with enable/visible conditions struct SettingWithConditions { @@ -593,9 +592,11 @@ std::shared_ptr CAddonSettings::ParseOldSettingElement(const TiXm // turn the setting into a reference setting setting = std::make_shared(settingId, GetSettingsManager()); } - - // add the setting's identifier to the list of all identifiers - settingIds.insert(setting->GetId()); + else + { + // add the setting's identifier to the list of all identifiers + settingIds.insert(setting->GetId()); + } // add the setting to the list of settings from the same category categorySettings.push_back(setting); @@ -646,7 +647,7 @@ std::shared_ptr CAddonSettings::ParseOldSettingElement(const TiXm return group; } -std::shared_ptr CAddonSettings::ParseOldCategoryElement(uint32_t &categoryId, const TiXmlElement * categoryElement, std::set &actionSettings) +std::shared_ptr CAddonSettings::ParseOldCategoryElement(uint32_t &categoryId, const TiXmlElement * categoryElement, std::set &actionSettings, std::set &settingIds) { // create the category auto category = std::make_shared(StringUtils::Format("category%u", categoryId), GetSettingsManager()); @@ -658,7 +659,7 @@ std::shared_ptr CAddonSettings::ParseOldCategoryElement(uint32 category->SetLabel(categoryLabel); // prepare a setting group - auto group = ParseOldSettingElement(categoryElement, category, actionSettings); + auto group = ParseOldSettingElement(categoryElement, category, actionSettings, settingIds); // add the group to the category category->AddGroup(group); @@ -680,14 +681,16 @@ bool CAddonSettings::InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc uint32_t categoryId = 0; std::set actionSettings; + // Settings id set + std::set settingIds; // Special case for no category settings - section->AddCategory(ParseOldCategoryElement(categoryId, root, actionSettings)); + section->AddCategory(ParseOldCategoryElement(categoryId, root, actionSettings, settingIds)); const TiXmlElement *categoryElement = root->FirstChildElement("category"); while (categoryElement != nullptr) { - section->AddCategory(ParseOldCategoryElement(categoryId, categoryElement, actionSettings)); + section->AddCategory(ParseOldCategoryElement(categoryId, categoryElement, actionSettings, settingIds)); // look for the next category categoryElement = categoryElement->NextSiblingElement("category"); diff --git a/xbmc/addons/settings/AddonSettings.h b/xbmc/addons/settings/AddonSettings.h index d4f52b82e8..fbf546a85a 100644 --- a/xbmc/addons/settings/AddonSettings.h +++ b/xbmc/addons/settings/AddonSettings.h @@ -74,9 +74,9 @@ namespace ADDON bool ParseSettingVersion(const CXBMCTinyXML& doc, uint32_t& version) const; - std::shared_ptr ParseOldSettingElement(const TiXmlElement *categoryElement, std::shared_ptr category, std::set& actionSettings); + std::shared_ptr ParseOldSettingElement(const TiXmlElement *categoryElement, std::shared_ptr category, std::set& actionSettings, std::set& settingIds); - std::shared_ptr ParseOldCategoryElement(uint32_t &categoryId, const TiXmlElement * categoryElement, std::set &actionSettings); + std::shared_ptr ParseOldCategoryElement(uint32_t &categoryId, const TiXmlElement * categoryElement, std::set &actionSettings, std::set& settingIds); bool InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc); std::shared_ptr InitializeFromOldSettingAction(std::string settingId, const TiXmlElement *settingElement, const std::string& defaultValue); -- cgit v1.2.3