Skip to content

BUG: Updating some preferences was not working

I noticed some code in the Settings window that read like:

if (cancel_button_pressed) {
   update_settings();
}

instead of what seemed to be the purpose of the developer:

if (save_button_pressed || window_was_closed) {
   update_settings();
}

So I went to check what kind of settings could be broken because of this. I found that, for example, changing the canvas border color doesn't work. Try these steps to see the unexpected behaviour:

  • Create a new file and zoom out until you can see the grey border color: image
  • Go to Settings > Configure Krita... > Display > Grid Settings
  • Change the "Canvas Border Color" to a darker grey and press "OK". Nothing should have changed.
  • Now go again to Go to Settings > Configure Krita.... And don't change anything, just press "OK".
  • Now you can see the configuration took effect: image

I tracked the bug to this commit: Set the preferences when closing the preferences dialog. You'll see the author wanted to make the "OK" and "Window X" button have the same effect, but an extra ! was added here: image

Because that editPreferences method returns return !m_cancelClicked;, then the double-negation is saying: "execute the update only if cancel was clicked".

Test Plan

Follow the reproduction steps above before testing my changes. You'll see the unexpected behaviour. Apply my changes and try again changing the "Canvas Border Color" and you'll see the desired color is updated at the first try.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Daniel Wilches

Merge request reports