https://bugs.kde.org/show_bug.cgi?id=395186

            Bug ID: 395186
           Summary: Document.selection() returns None when selection
                    created by Action is still processing.
           Product: krita
           Version: 4.0.3
          Platform: Appimage
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Scripting
          Assignee: krita-bugs-n...@kde.org
          Reporter: gbird...@gmail.com
  Target Milestone: ---

Created attachment 113176
  --> https://bugs.kde.org/attachment.cgi?id=113176&action=edit
File for testing

When I try to create selection from Action for example 'selectopaque' and then
fetch it with s = doc.selection() most of the time I will get s == None.
If I run the same code again when selection already exists doc.selection()
returns actual selection.

Steps:
1 Open Attached test file
2 Select layer with green circle
3 Run this script in Scripter

from krita import *

k = Krita.instance()
d = k.activeDocument()

def test_selection():
    k.action('selectopaque').trigger()

    s = d.selection()
    if s == None:
        print("Yes...")
    else:
        print("No O_O")

    s.invert()
    d.setSelection(s)
    d.refreshProjection()       

test_selection()
#test_selection()

Result:
Krita will creates selection from the green circle.
Scripter throws: AttributeError: 'NoneType' object has no attribute 'invert'

Expected result:
Krita creates selection from the green circle and inverts this selection.

4 Remove selection from the Image
5 Uncomment last line of the script so test_selection() will be run 2 times in
a row.
6 Run script again

Result:
As expected. Inverted selection from green circle.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to