Skip to content

Loading settings from a file does not handle default values the way I would expect #18558

@belaroesener

Description

@belaroesener

Problem Description

Settings can not be reset to their default value by loading them from a settings file. This creates problematic behavior in different workflows relying on the settings file mechanism, like synchronizing settings between two images or restoring settings to their previous values after trying out changes to the settings.

Problem Reproduction

This reproduction is the simplest case of "misbehavior" and illustrates the mismatch between my expectation and the actual behavior.
I will use Code Browsing > Quality Assistant > Criticize final dot in method body (CFD) as an example setting, because it is a toggle rule with a constant default value of true, i.e. it is a very simple kind of setting.

  1. Open a SettingBrowser and check that CFD is on (which is the default)
  2. Store settings
  3. Set CFD to off
  4. Load settings (either in the same, or in another image)
  5. => CFD remains off

As opposed to this, the following works as I would expect:

  1. Set CFD to off
  2. Store settings
  3. Set CFD to on
  4. Load settings
  5. => CFD is set to off

The above behavior is a problem if I want to try out a few settings and then change them back to their previous values using the settings file mechanism. It is also a problem if I want to use the same settings in multiple images, using a settings file to synchronize all changes between the images.

Expected Behavior

When I store the settings of an image, I expect that loading them again restores them completely. (Both when (re)loading the settings in the same image at a later point in time, as well as when loading them into a second image.)
In other words, I expect that loading a settings file (re)sets the settings to the same values they were when I stored the them.

Explanation

When the settings are stored, only the settings that have a value different from their default value are actually written to the settings file. When these settings are loaded, the settings in the file are used to set the corresponding settings in the image. But the absence of a setting from the settings file does not affect the corresponding setting in the image.
This is a problem, because if a setting does not occur in the settings file, it had its default value when the settings file was created. The loading process should reflect this by ensuring that a setting in the image, that was not stored in the settings file, has its default value after loading the settings file.

Solution

When loading a settings file we can infer that all settings not in the settings file had their default value in the image that created the file. Therefore we can reset each setting that was not mentioned in the settings file, to its default value (if it has one).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions