Skip to content
This repository
Browse code

Delete settings category if it already exists in CSettingsGroup::AddC…

…ategory()
  • Loading branch information...
commit bdef87ba1ef399498b4b1da561d50437385f8ab8 1 parent 6db72f9
Garrett Brown authored March 26, 2013
18  xbmc/settings/GUISettings.cpp
@@ -226,6 +226,24 @@ CSettingAddon::CSettingAddon(int iOrder, const char *strSetting, int iLabel, con
226 226
 {
227 227
 }
228 228
 
  229
+CSettingsCategory* CSettingsGroup::AddCategory(const char *strCategory, int labelID)
  230
+{
  231
+  // Remove the category if it already exists
  232
+  for (vecSettingsCategory::iterator it = m_vecCategories.begin(); it != m_vecCategories.end(); it++)
  233
+  {
  234
+    if ((*it)->m_strCategory.Equals(strCategory))
  235
+    {
  236
+      delete (*it);
  237
+      m_vecCategories.erase(it);
  238
+      break;
  239
+    }
  240
+  }
  241
+  CSettingsCategory *pCategory = new CSettingsCategory(strCategory, labelID);
  242
+  if (pCategory)
  243
+    m_vecCategories.push_back(pCategory);
  244
+  return pCategory;
  245
+}
  246
+
229 247
 void CSettingsGroup::GetCategories(vecSettingsCategory &vecCategories)
230 248
 {
231 249
   vecCategories.clear();
8  xbmc/settings/GUISettings.h
@@ -436,13 +436,7 @@ class CSettingsGroup
436 436
     m_vecCategories.clear();
437 437
   };
438 438
 
439  
-  CSettingsCategory* AddCategory(const char *strCategory, int labelID)
440  
-  {
441  
-    CSettingsCategory *pCategory = new CSettingsCategory(strCategory, labelID);
442  
-    if (pCategory)
443  
-      m_vecCategories.push_back(pCategory);
444  
-    return pCategory;
445  
-  }
  439
+  CSettingsCategory* AddCategory(const char *strCategory, int labelID);
446 440
   void GetCategories(vecSettingsCategory &vecCategories);
447 441
   int GetLabelID() { return m_labelID; };
448 442
   int GetGroupID() { return m_groupID; };

0 notes on commit bdef87b

Please sign in to comment.
Something went wrong with that request. Please try again.