Bug 421575 - Paths in kis_paintoppresets.blacklist containing backward slashes are ignored
Summary: Paths in kis_paintoppresets.blacklist containing backward slashes are ignored
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: 4.3.0-beta1
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-15 17:33 UTC by Leonardo
Modified: 2020-10-16 19:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leonardo 2020-05-15 17:33:34 UTC
SUMMARY

Paths in kis_paintoppresets.blacklist use / (forward slash) as directory separator, except that SOMETIMES the last directory separator becomes a \ (backward slash) instead. When this happens, Krita fails at blacklisting the path and overwritten brush presets, backups, etc. show up in the brush list.

I'm not familiar with the code, but it's possible that somewhere Krita checks if a preset filepath matches the blacklist entries EXACTLY (e.g. filepath_a == filepath_b) and that fails, or some function to resolve paths into their canonical versions fails at resolving backward slashes on Windows, or something like that. Anyway, the simplest fix is to stop using backward slashes in blacklisted paths, or to replace "paintoppresets\" with "paintoppresets/" before comparing paths.

STEPS TO REPRODUCE
1. Select the brush b)_Basic-2_Opacity.
2. On the brush settings editor, click "Save new brush preset..." and save as "Test".
3. Select the brush Test.
4. On the brush settings editor, change a setting. E.g. click on the "size" checkbox to change size with pressure.
5. Click "overwrite brush".

OBSERVED RESULT

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE m_blackListFile>
<resourceFilesList>
 <file>
  <name>~/AppData/Roaming/krita/paintoppresets\Test_backup_2020-05-15-140459.kpp</name>
 </file>
</resourceFilesList>

The "Test" preset shows twice on Krita because the backup isn't blacklisted.

EXPECTED RESULT

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE m_blackListFile>
<resourceFilesList>
 <file>
  <name>~/AppData/Roaming/krita/paintoppresets/Test_backup_2020-05-15-140459.kpp</name>
 </file>
</resourceFilesList>

The "Test" preset shows once on Krita as the backup is properly blacklisted.

SOFTWARE/OS VERSIONS
Windows 7 (64bit)
Krita 4.3.0-beta1 (git 5149f63)

ADDITIONAL INFORMATION

Manually editing kis_paintoppresets.blacklist with Notepad++ and replacing \ with / fixes the issue.

It seems that SOMETIMES blacklisted paths are added correctly, with /, while other times they were added incorrectly, with \. This suggests that the bug only happens under certain circumstances, and that the code to add entries to the blacklist has two different ways to generate paths, one with /, another with \, which alternate sometimes for some reason.
Comment 1 Halla Rempt 2020-05-17 09:48:03 UTC
Git commit eefadb8790c9df23c5ee184d529a8d275e611a14 by Boudewijn Rempt.
Committed on 17/05/2020 at 09:30.
Pushed by rempt into branch 'master'.

Do not use QDir::separator to build file paths

Since https://doc.qt.io/qt-5/qdir.html#separator says

"You do not need to use this function to build file paths. If you always
use "/", Qt will translate your paths to conform to the underlying
operating system. "

M  +1    -1    benchmarks/kis_bcontrast_benchmark.cpp
M  +1    -1    benchmarks/kis_blur_benchmark.cpp
M  +1    -1    benchmarks/kis_filter_selections_benchmark.cpp
M  +1    -1    benchmarks/kis_level_filter_benchmark.cpp
M  +1    -1    benchmarks/kis_low_memory_benchmark.cpp
M  +3    -3    benchmarks/kis_projection_benchmark.cpp
M  +2    -2    benchmarks/kis_stroke_benchmark.cpp
M  +4    -4    libs/brush/tests/TestAbrStorage.cpp
M  +3    -3    libs/brush/tests/kis_auto_brush_test.cpp
M  +9    -9    libs/brush/tests/kis_gbr_brush_test.cpp
M  +5    -5    libs/brush/tests/kis_imagepipe_brush_test.cpp
M  +2    -2    libs/flake/svg/SvgLoadingContext.cpp
M  +1    -1    libs/flake/svg/SvgParser.cpp
M  +2    -2    libs/image/kis_image_config.cpp
M  +1    -1    libs/image/tests/kis_asl_parser_test.cpp
M  +6    -6    libs/image/tests/kis_async_merger_test.cpp
M  +2    -2    libs/image/tests/kis_convolution_painter_test.cpp
M  +1    -1    libs/image/tests/kis_cs_conversion_test.cpp
M  +4    -4    libs/image/tests/kis_filter_mask_test.cpp
M  +6    -6    libs/image/tests/kis_filter_test.cpp
M  +7    -7    libs/image/tests/kis_fixed_paint_device_test.cpp
M  +13   -13   libs/image/tests/kis_paint_device_test.cpp
M  +1    -1    libs/image/tests/kis_paint_layer_test.cpp
M  +2    -2    libs/image/tests/kis_pattern_test.cpp
M  +3    -3    libs/image/tests/kis_processing_applicator_test.cpp
M  +26   -26   libs/image/tests/kis_transform_worker_test.cpp
M  +3    -3    libs/image/tests/kis_transparency_mask_test.cpp
M  +4    -4    libs/image/tests/kis_update_scheduler_test.cpp
M  +1    -1    libs/image/tiles3/swap/kis_memory_window.cpp
M  +2    -2    libs/pigment/resources/KoPattern.cpp
M  +1    -1    libs/resources/KoResourcePaths.cpp
M  +3    -3    libs/ui/KisDocument.cpp
M  +2    -2    libs/ui/KisFrameDataSerializer.cpp
M  +1    -1    libs/ui/KisTemplateTree.cpp
M  +2    -2    libs/ui/dialogs/kis_dlg_layer_style.cpp
M  +1    -1    libs/ui/kis_mimedata.cpp
M  +1    -1    libs/ui/kis_safe_document_loader.cpp
M  +1    -1    libs/ui/tests/filter_stroke_test.cpp
M  +6    -6    libs/ui/tests/kis_animation_importer_test.cpp
M  +2    -2    libs/ui/tests/kis_doc2_test.cpp
M  +4    -4    libs/ui/tests/kis_prescaled_projection_test.cpp
M  +1    -1    libs/widgetutils/config/kcolorschememanager.cpp
M  +1    -1    plugins/dockers/gamutmask/gamutmask_dock.cpp
M  +4    -4    plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
M  +1    -1    plugins/extensions/animationrenderer/video_saver.cpp
M  +1    -1    plugins/extensions/resourcemanager/dlg_bundle_manager.cpp
M  +9    -9    plugins/filters/tests/kis_all_filter_test.cpp
M  +2    -2    plugins/filters/tests/kis_crash_filter_test.cpp
M  +2    -2    plugins/impex/libkra/tests/kis_kra_loader_test.cpp
M  +13   -13   plugins/impex/psd/tests/kis_psd_test.cpp
M  +1    -1    plugins/tools/basictools/tests/move_stroke_test.cpp
M  +6    -6    sdk/tests/qimage_based_test.h
M  +9    -9    sdk/tests/qimage_test_util.h
M  +4    -4    sdk/tests/stroke_testing_utils.cpp

https://invent.kde.org/graphics/krita/commit/eefadb8790c9df23c5ee184d529a8d275e611a14
Comment 2 Halla Rempt 2020-07-28 12:29:13 UTC
Should be fixed with that commit.
Comment 3 Tiar 2020-10-16 19:27:07 UTC
Git commit fef9c7ff8610e5ed4a97cb965745a67af5865668 by Agata Cacko, on behalf of Boudewijn Rempt.
Committed on 16/10/2020 at 16:07.
Pushed by tymond into branch 'krita/4.3'.

Do not use QDir::separator to build file paths

Since https://doc.qt.io/qt-5/qdir.html#separator says

"You do not need to use this function to build file paths. If you always
use "/", Qt will translate your paths to conform to the underlying
operating system. "

M  +1    -1    benchmarks/kis_bcontrast_benchmark.cpp
M  +1    -1    benchmarks/kis_blur_benchmark.cpp
M  +1    -1    benchmarks/kis_filter_selections_benchmark.cpp
M  +1    -1    benchmarks/kis_level_filter_benchmark.cpp
M  +1    -1    benchmarks/kis_low_memory_benchmark.cpp
M  +3    -3    benchmarks/kis_projection_benchmark.cpp
M  +2    -2    benchmarks/kis_stroke_benchmark.cpp
M  +3    -3    libs/brush/tests/kis_auto_brush_test.cpp
M  +9    -9    libs/brush/tests/kis_gbr_brush_test.cpp
M  +5    -5    libs/brush/tests/kis_imagepipe_brush_test.cpp
M  +2    -2    libs/flake/svg/SvgLoadingContext.cpp
M  +1    -1    libs/flake/svg/SvgParser.cpp
M  +2    -2    libs/image/kis_image_config.cpp
M  +1    -1    libs/image/tests/kis_asl_parser_test.cpp
M  +6    -6    libs/image/tests/kis_async_merger_test.cpp
M  +2    -2    libs/image/tests/kis_convolution_painter_test.cpp
M  +1    -1    libs/image/tests/kis_cs_conversion_test.cpp
M  +4    -4    libs/image/tests/kis_filter_mask_test.cpp
M  +6    -6    libs/image/tests/kis_filter_test.cpp
M  +7    -7    libs/image/tests/kis_fixed_paint_device_test.cpp
M  +13   -13   libs/image/tests/kis_paint_device_test.cpp
M  +1    -1    libs/image/tests/kis_paint_layer_test.cpp
M  +2    -2    libs/image/tests/kis_pattern_test.cpp
M  +3    -3    libs/image/tests/kis_processing_applicator_test.cpp
M  +26   -26   libs/image/tests/kis_transform_worker_test.cpp
M  +3    -3    libs/image/tests/kis_transparency_mask_test.cpp
M  +4    -4    libs/image/tests/kis_update_scheduler_test.cpp
M  +1    -1    libs/image/tiles3/swap/kis_memory_window.cpp
M  +2    -2    libs/pigment/resources/KoPattern.cpp
M  +3    -3    libs/ui/KisDocument.cpp
M  +2    -2    libs/ui/KisFrameDataSerializer.cpp
M  +1    -1    libs/ui/KisTemplateTree.cpp
M  +4    -4    libs/ui/animation/KisDlgAnimationRenderer.cpp
M  +1    -1    libs/ui/animation/KisVideoSaver.cpp
M  +1    -1    libs/ui/dialogs/kis_dlg_layer_style.cpp
M  +1    -1    libs/ui/kis_mimedata.cpp
M  +1    -1    libs/ui/kis_safe_document_loader.cpp
M  +1    -1    libs/ui/tests/filter_stroke_test.cpp
M  +6    -6    libs/ui/tests/kis_animation_importer_test.cpp
M  +2    -2    libs/ui/tests/kis_doc2_test.cpp
M  +4    -4    libs/ui/tests/kis_prescaled_projection_test.cpp
M  +1    -1    libs/widgetutils/KoResourcePaths.cpp
M  +1    -1    libs/widgetutils/config/kcolorschememanager.cpp
M  +1    -1    plugins/dockers/gamutmask/gamutmask_dock.cpp
M  +9    -9    plugins/filters/tests/kis_all_filter_test.cpp
M  +2    -2    plugins/filters/tests/kis_crash_filter_test.cpp
M  +2    -2    plugins/impex/libkra/tests/kis_kra_loader_test.cpp
M  +13   -13   plugins/impex/psd/tests/kis_psd_test.cpp
M  +1    -1    plugins/tools/basictools/tests/move_stroke_test.cpp
M  +6    -6    sdk/tests/qimage_based_test.h
M  +9    -9    sdk/tests/qimage_test_util.h
M  +4    -4    sdk/tests/stroke_testing_utils.cpp

https://invent.kde.org/graphics/krita/commit/fef9c7ff8610e5ed4a97cb965745a67af5865668