-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to heal settings files damaged by #9962 #10143
Conversation
The bug that caused #9962 resulted in folks getting profiles written to their settings that didn't contain any identifying information (name or guid), sometimes multiple times. These profiles look (somewhat) like this: ```json { "colorScheme": "Campbell" }, {}, ``` An empty profile serves no purpose -- it shows up in the list as being named "Default", and it only launches CMD (unless the commandline is the thing that the user successfully changed.) We can heal the settings file by simply ignoring those profiles that have *no identifying information* (a guid or a name that can be converted into a guid). Validation ---------- I created a number of profiles that fit this format and made sure that they were ignored on load and destroyed on save.
static bool _IsValidProfileObject(const Json::Value& profileJson) | ||
{ | ||
return profileJson.isMember(&*NameKey.begin(), &*NameKey.end()) || // has a name (can generate a guid) | ||
profileJson.isMember(&*GuidKey.begin(), &*GuidKey.end()); // or has a guid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frick, I meant to fix this -- this will throw in debug
return profileJson.isMember(&*NameKey.cbegin(), (&*NameKey.cbegin()) + NameKey.size()) || // has a name (can generate a guid) | ||
profileJson.isMember(&*GuidKey.cbegin(), (&*GuidKey.cbegin()) + GuidKey.size()); // or has a guid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know, the iterator math is ugly. this is the alternative to creating a copy of the name/guid string views as strings every time we want to check.
This should be in JsonUtils as another "string_view adapter" (like GetValue and SetValue do), but I am not doing this in this PR.
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
The bug that caused #9962 resulted in folks getting profiles written to their settings that didn't contain any identifying information (name or guid), sometimes multiple times. These profiles look (somewhat) like this: ```json { "colorScheme": "Campbell" }, {}, ``` An empty profile serves no purpose -- it shows up in the list as being named "Default", and it only launches CMD (unless the commandline is the thing that the user successfully changed.) We can heal the settings file by simply ignoring those profiles that have *no identifying information* (a guid or a name that can be converted into a guid). Validation ---------- I created a number of profiles that fit this format and made sure that they were ignored on load and destroyed on save. ## PR Checklist * [x] Closes an annoyance we discovered after 9962. (cherry picked from commit 84f6a29)
🎉 Handy links: |
🎉 Handy links: |
The bug that caused #9962 resulted in folks getting profiles written to
their settings that didn't contain any identifying information (name or
guid), sometimes multiple times.
These profiles look (somewhat) like this:
An empty profile serves no purpose -- it shows up in the list as being
named "Default", and it only launches CMD (unless the commandline is the
thing that the user successfully changed.)
We can heal the settings file by simply ignoring those profiles that
have no identifying information (a guid or a name that can be
converted into a guid).
Validation
I created a number of profiles that fit this format and made sure that
they were ignored on load and destroyed on save.
PR Checklist