Retain configuration meta data on ProjectSettings #67579
Closed
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.
This is a brute force fix for #25661 (and similar bug reports). It's probably good enough but it's worth having a discussion whether we want to make much more work out of this.
The core problem here is that when we select a project from the list and do something with it, we instantiate a new instance of
ProjectSettings
. At this point in time that projects settings takes over as the singleton in memory and we loose access to the original singleton created at startup that contains our full set of registered settings especially now that we only save settings that the user has changed from default.This results in two sets of behaviors:
(and then a 3rd potential issue is that we could destroy our new
ProjectSettings
object and have our singleton pointer becomes anullptr
)A brute way to solve this is to check if we already have a singleton in our constructor, make a copy of our properties and set everything to default, this is what I'm doing here but it only solves issue number 2 and not in a consistent way.
The nice way to solve it would be that only our object constructed in main becomes our singleton, and the additional objects don't, but our whole API for accessing settings is based around our singleton access. This would be a major undertaking to ensure that our macros are only used for accessing the settings loaded at startup, and any access to settings within the class itself and when the project manager access settings for other projects, we do not rely on the singleton logic.
We could still merge this as an interim solution as it makes nothing worse than it already is, and look at doing the work to make it nicer some time in the future.