Bug 416793

Summary: API creates broken layer masks
Product: [Applications] krita Reporter: Kapyia <kapyia.art>
Component: ScriptingAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: griffinvalley, halla
Priority: NOR    
Version First Reported In: 4.2.8   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Script to create a mask node

Description Kapyia 2020-01-26 16:14:29 UTC
Created attachment 125442 [details]
Script to create a mask node

This problem was brought to light thanks to Frohman and tiar over at Krita-Artists.org. There's currently a problem with the libkis API where trying to create a mask node of any kind results in an empty/broken layer mask object. The created node always has the name "effect" (kis_effect_mask.cc, line 27) and has no bounds/size.

From what I can tell, the problem stems from the method 'createNode' in Document.cpp creating mask nodes somewhat incorrectly, resulting in them being "incomplete". On my system it also leads to a crash when I try to make Krita display the mask (eg. trying to isolate the layer).

I've attached a small script that helps reproduce the problem in Krita.
Comment 1 wolthera 2020-01-26 16:43:57 UTC
If tiar and frohman can reproduce it, let's mark it as confirmed.
Comment 2 Halla Rempt 2020-04-15 14:14:33 UTC
Git commit c1e18cedea1e404bc8b1727f22dbe8282d6e1024 by Boudewijn Rempt.
Committed on 15/04/2020 at 14:14.
Pushed by rempt into branch 'master'.

Create masks from python with the given name

The mask itself was fine; but the name wasn't passed through.

M  +2    -2    libs/image/kis_effect_mask.cc
M  +1    -1    libs/image/kis_effect_mask.h
M  +2    -2    libs/image/kis_filter_mask.cpp
M  +1    -1    libs/image/kis_filter_mask.h
M  +1    -1    libs/image/kis_image.cc
M  +1    -1    libs/image/kis_layer_utils.cpp
M  +2    -2    libs/image/kis_selection_mask.cpp
M  +1    -1    libs/image/kis_selection_mask.h
M  +2    -2    libs/image/kis_transform_mask.cpp
M  +2    -2    libs/image/kis_transform_mask.h
M  +2    -2    libs/image/kis_transparency_mask.cc
M  +1    -1    libs/image/kis_transparency_mask.h
M  +3    -2    libs/image/lazybrush/kis_colorize_mask.cpp
M  +1    -1    libs/image/lazybrush/kis_colorize_mask.h
M  +5    -4    libs/libkis/Document.cpp
M  +1    -1    libs/ui/dialogs/kis_dlg_filter.cpp

https://invent.kde.org/kde/krita/commit/c1e18cedea1e404bc8b1727f22dbe8282d6e1024
Comment 3 Halla Rempt 2020-04-17 07:31:52 UTC
Git commit b62d9cdb99adc0cb9e21df80afdeeefbd161cd5a by Boudewijn Rempt.
Committed on 17/04/2020 at 07:22.
Pushed by rempt into branch 'krita/4.3'.

Create masks from python with the given name

The mask itself was fine; but the name wasn't passed through.
(cherry picked from commit c1e18cedea1e404bc8b1727f22dbe8282d6e1024)

M  +2    -2    libs/image/kis_effect_mask.cc
M  +1    -1    libs/image/kis_effect_mask.h
M  +3    -2    libs/image/kis_filter_mask.cpp
M  +1    -1    libs/image/kis_filter_mask.h
M  +1    -1    libs/image/kis_image.cc
M  +1    -1    libs/image/kis_layer_utils.cpp
M  +2    -2    libs/image/kis_selection_mask.cpp
M  +1    -1    libs/image/kis_selection_mask.h
M  +2    -2    libs/image/kis_transform_mask.cpp
M  +2    -2    libs/image/kis_transform_mask.h
M  +2    -2    libs/image/kis_transparency_mask.cc
M  +1    -1    libs/image/kis_transparency_mask.h
M  +3    -2    libs/image/lazybrush/kis_colorize_mask.cpp
M  +1    -1    libs/image/lazybrush/kis_colorize_mask.h
M  +5    -4    libs/libkis/Document.cpp
M  +1    -1    libs/ui/dialogs/kis_dlg_filter.cpp

https://invent.kde.org/kde/krita/commit/b62d9cdb99adc0cb9e21df80afdeeefbd161cd5a