Page MenuHomeWildfire Games

Warn if GUI object base and derived class call AddSetting for the same property

Authored by elexis on Sep 23 2019, 12:20 AM.



Following rP22958 (related but not dependent cleanup in rP22952, rP22969) and this Dropdown diff, we can show a warning if a C++ author calls AddSetting on the same property more than once instead of silently ignoring that.
If there is code (especially C++ code), the reader thinks the code is purposeful, but in these cases its misleading as the setting was registered already.
If the derived class calls AddSetting it implies that the derived class has the freedom to chose the type T, when it hasn't, hence misleading.
The AddSetting call should be in the class that has all the GetSetting calls to it.

So this LOGERROR will help structure (keep structured) the codebase so that AddSetting and GetSetting calls will be in the same class, thus allowing to make those setting values members,
so that the class using them will be able to access them more quickly, as laid out by Vladislav in
Refs D2313

Test Plan

That all current GUI object types don't run into this LOGERROR any further can be tested by running a game, opening options page, summary screen, savegame screen.

Diff Detail

rP 0 A.D. Public Repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Sep 23 2019, 12:20 AM

Successful build - Chance fights ever on the side of the prudent.

Link to build:

Successful build - Chance fights ever on the side of the prudent.

Link to build:

elexis edited the summary of this revision. (Show Details)Sep 23 2019, 12:43 AM
This revision was not accepted when it landed; it landed in state Needs Review.Sep 23 2019, 12:49 AM
This revision was automatically updated to reflect the committed changes.