From e67f3648876e8a2efbd2c559ffdea60cdeb31f0e Mon Sep 17 00:00:00 2001 From: elexis Date: Sun, 22 Sep 2019 22:49:20 +0000 Subject: [PATCH] Warn if the derived class and the base class have the same AddSetting call instead of silently ignoring it. Enabled by f69261d37b (refs d412b2010b / D2314, 7bb0f2ea69 / D2318). Helps structuring the GUI so that AddSetting and GetSetting are in the same file, which defragments code and may allow for future optimizations (setting values as class members for Draw calls), refs D2313. Differential Revision: https://code.wildfiregames.com/D2320 Tested on: clang 8.0.1, Jenkins This was SVN commit r22975. --- source/gui/CDropDown.cpp | 5 +---- source/gui/IGUIObject.cpp | 7 +++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/gui/CDropDown.cpp b/source/gui/CDropDown.cpp index aa3795987c..be44c50514 100644 --- a/source/gui/CDropDown.cpp +++ b/source/gui/CDropDown.cpp @@ -34,13 +34,11 @@ CDropDown::CDropDown(CGUI& pGUI) AddSetting("dropdown_size"); AddSetting("dropdown_buffer"); AddSetting("minimum_visible_items"); -// AddSetting("sound_closed"); - AddSetting("sound_disabled"); AddSetting("sound_enter"); AddSetting("sound_leave"); AddSetting("sound_opened"); - AddSetting("sprite"); // Background that sits around the size + // Setting "sprite" is registered by CList and used as the background AddSetting("sprite_disabled"); AddSetting("sprite_list"); // Background of the drop down list AddSetting("sprite2"); // Button that sits to the right @@ -52,7 +50,6 @@ CDropDown::CDropDown(CGUI& pGUI) // Add these in CList! And implement TODO //AddSetting("textcolor_over"); //AddSetting("textcolor_pressed"); - AddSetting("textcolor_selected"); AddSetting("textcolor_disabled"); // Scrollbar is forced to be true. diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index fda54034a2..dfa79b10e4 100644 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -116,11 +116,10 @@ void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) template void IGUIObject::AddSetting(const CStr& Name) { - // This can happen due to inheritance if (SettingExists(Name)) - return; - - m_Settings[Name] = new CGUISetting(*this, Name); + LOGERROR("The setting '%s' already exists on the object '%s'!", Name.c_str(), GetPresentableName().c_str()); + else + m_Settings.emplace(Name, new CGUISetting(*this, Name)); } bool IGUIObject::SettingExists(const CStr& Setting) const