Skip to content

Automatic filename renames for imported and added resources

Before this commit, multiple operations done by the user would end up with error, often silent error. This commit ensures that the resource file will be imported or the resource will be added even if the original filename is already taken.

Note: it would be best to first ask the user. However we're in the string freeze. Better to have a working default than not.

Test Plan

Test files: pattern pattern_A

Test 1.

  1. Rename pattern_A.png to be pattern.png. Import as Brush Tip.
  2. Rename pattern_B.png to be pattern.png. Import as Brush Tip.
  3. Both should be visible in Resource Manager. (Before this MR, it would fail).
  4. Rename pattern_A.png to be pattern.png. Import as Brush Tip.
  5. The last one won't show up, because it has the same MD5 as the original pattern.png. (Before this MR, it would fail).

Test 2.

  1. Rename pattern_A.png to be pattern.png. Import as Brush Tip.
  2. Rename pattern_B.png to be pattern.png. Import as Brush Tip.
  3. Both should be visible in Resource Manager. (Before this MR, it would fail).
  4. Rename pattern_B.png to be pattern.png. Import as Brush Tip.
  5. The last one will show up, because it doesn't have the same MD5 as the original pattern.png. This is an unfortunate event and it would be best to get it fixed. (Doesn't need to be in this MR though, I guess). (Before this MR, it would fail).

Test 3.

  1. Open Brush Editor, take some Pixel Brush as template.
  2. Use Save New Brush Preset, use name "Test A".
  3. Use Save New Brush Preset again, use the same name.
  4. Before this MR: it would fail. After this MR: it will succeed.

Test 3.

  1. Open Brush Editor, take some Pixel Brush as template.
  2. Use Save New Brush Preset, use name "Test B".
  3. Delete the "Test B" brush preset using any method.
  4. Use Save New Brush Preset again, use the same name.
  5. Before this MR: it would fail. After this MR: it will succeed.

https://bugs.kde.org/show_bug.cgi?id=439128 Also relevant: https://krita-artists.org/t/resource-bugs-in-krita-5/23235/25?u=tiar

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.

Merge request reports

Loading