Remove duplicate editor settings definitions #58847
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that
EDITOR_DEF
is overused in many places. This is a very bad idea, because each time you use EDITOR_DEF,a cat starts crying somewhereyou need to provide a default value. This leads to some ridiculous situations like a default value repeated 7 times. The actual value then depends on initialization order. Luckily I spotted only one setting that had inconsistent defaults across definitions.My absolute favorite was this:
Same thing, defined twice few lines apart.
I went over the codebase and cleaned it up by removing duplicate defs of the same settings and changing them to EDITOR_GET. We have most of the settings defined in
_load_defaults()
method of EditorSettings, so if there were some additional EDITOR_DEFs, I left the ones in the singleton. Then I left stuff defined in a constructor over inlined settings. If some settings were on equivalent level (i.e. not apparent which one comes first), I moved the definition to_load_defaults()
.We should have some policy for using
EDITOR_DEF
. Repeating defaults multiple times can lead to errors, but also IMO it's just dumb xdAnother things to consider could be:
_load_defaults()
, so they are all in one placeEditorSettings::get_singleton()->get()
toEDITOR_GET
(it's the same thing, except it displays error when setting is missing and also it's much shorter)Also Project Settings likely need the same treatment.