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

            Bug ID: 434244
           Summary: Annotation not loaded
           Product: krita
           Version: git master
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Scripting
          Assignee: krita-bugs-n...@kde.org
          Reporter: grum...@grum.fr
  Target Milestone: ---

SUMMARY

I'm testing annotations that have been implemented with Krita 5

I'm facing an issue on annotation loading, when more than one annotation is
saved in document.

- Annotations are OK when just created (possible to access all annotations)
- Annotations are KO after document is loaded
  . All annotations are visible
  . All annotations identifier are OK
  . All annotations description are OK
  . Annotations data are KO => only the last one is loaded

Looking kra file, everything is OK:
- maindoc.xml => all annotations are present
- all annotations files => present and contains expected data

So it’s seems problem is during file loading, only the last annotation content
is loaded.

STEPS TO REPRODUCE
1. With Python Scripting, execute following script:

# ------------------------------------
from krita import *

fileName="/home/grum/Temporaire/test.kra"

doc = Krita.instance().createDocument(300, 300, "Test", "RGBA", "U8", "",
300.0)
#Krita.instance().activeWindow().addView(doc)

for i in range(3):
    text=f"{i}={i*' * '}"
    doc.setAnnotation(f'test{i}', f"description {i}",
QByteArray(text.encode()))

print("-set------------")
for annotation in doc.annotationTypes():
    print("annotation: ", annotation, "description: ",
doc.annotationDescription(annotation))
    ba=doc.annotation(annotation)
    print(bytes(ba).decode())

doc.saveAs(fileName)
doc.close()


doc=Krita.instance().openDocument(fileName)

print("-loaded------------")
for annotation in doc.annotationTypes():
    print("annotation: ", annotation, "description: ",
doc.annotationDescription(annotation))
    ba=doc.annotation(annotation)
    print(bytes(ba).decode())

doc.close()
# ------------------------------------


OBSERVED RESULT
The following result is displayed on output:
# ------------------------------------

-set------------
annotation:  test0 description:  description 0
0=
annotation:  test1 description:  description 1
1= * 
annotation:  test2 description:  description 2
2= *  * 
-loaded------------
annotation:  test2 description:  description 2
2= *  * 
annotation:  test1 description:  description 1

annotation:  test0 description:  description 0

# ------------------------------------


EXPECTED RESULT
The following expected result should be displayed on output:
# ------------------------------------
-loaded------------
annotation:  test0 description:  description 0
0=
annotation:  test1 description:  description 1
1= * 
annotation:  test2 description:  description 2
2= *  * 
# ------------------------------------
==> loaded data should match with data that have been saved



SOFTWARE/OS VERSIONS
Windows: not tested
macOS: not tested
Linux/KDE Plasma: Debian 10 (Krita 5 prealpha appimage)


ADDITIONAL INFORMATION
Problem seems not to be located in Python API but in core implementation:
- Open document with more than one annotation.
- In menu "Images > Properties", Tab "Annotations"
  => we can see all annotations listed, but data are available only for the
last one (so for me problem is not only related to Python API)

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

Reply via email to