Bug 390853 - Libkis documents leak when one of the nodes is a file layer.
Summary: Libkis documents leak when one of the nodes is a file layer.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-21 16:17 UTC by wolthera
Modified: 2018-02-27 14:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wolthera 2018-02-21 16:17:45 UTC
Related to https://bugs.kde.org/show_bug.cgi?id=390725

Libkis documents don't close properly when the document contains a file layer. It gives the same safe-assert as 390725, but the latter bug has been solved for all other cases.
Comment 1 wolthera 2018-02-21 16:18:06 UTC
Ah, safe asserts ought to be crashes, apparantly.
Comment 2 Halla Rempt 2018-02-21 17:57:53 UTC
What does your script look like? If I run the following in Scripter, I do not get a crash:

------------------------
def test():
    d = Application.createDocument(100, 100, "Test", "RGBA", "U8", "", 120.0)

    root = d.rootNode();
    print(root.childNodes())
    l2 = d.createFileLayer("fl", "/home/boud/Pictures/environments-16-ziggurat-view_1920x489.png", "ImageToSize")
    print(l2)
    root.addChildNode(l2, None)
    print(root.childNodes())
    d.close()


test()
--------------------------------
Comment 3 wolthera 2018-02-22 11:56:52 UTC
Uhm, well, I noticed it when running the comic project management tools, and that it only happened with a layer which contents contained file layers. I cannot reproduce it with your script either. Are you sure it produces a valid file layer?

I do get it with:
-------------------

import sys
from krita import *

def test():
    d = Application.openDocument(Application.recentDocuments()[-1])

    root = d.rootNode();
    print(root.childNodes())
    l2 = d.createFileLayer("fl", "/home/boud/Pictures/environments-16-ziggurat-view_1920x489.png", "ImageToSize")
    print(l2)
    root.addChildNode(l2, None)
    print(root.childNodes())
    d.close()


test()

-------------------

Where the last document I had open was a file with a file layer.
Comment 4 wolthera 2018-02-22 11:57:44 UTC
Before you ask, yes, I did try changing the file layer url in the script to something else, but it made no difference to creating it.
Comment 5 Halla Rempt 2018-02-22 14:12:12 UTC
Curious: I get this on the output:

"Test"
Cloning KisFileLayer "../environments-16-ziggurat-view_1920x489.png"
SAFE ASSERT (krita): "QFile::exists(path())" in file /home/boud/dev/krita/libs/ui/kis_file_layer.cpp, line 80


And the resulting file misses the Pictures part of the url. I wonder what's up with that.
Comment 6 Halla Rempt 2018-02-23 15:49:22 UTC
Git commit b254dbad8019427b22b357284ef5b33c9698a4d5 by Boudewijn Rempt.
Committed on 23/02/2018 at 15:49.
Pushed by rempt into branch 'master'.

Do not set the url of the document based on the name

This leads to strange bugs because the url is set to
Pictures/name, but the document hasn't been saved yet.
Related: bug 297989

M  +1    -4    libs/ui/KisDocument.cpp

https://commits.kde.org/krita/b254dbad8019427b22b357284ef5b33c9698a4d5
Comment 7 Halla Rempt 2018-02-27 13:04:26 UTC
Damn, it still doesn't work. Now I get ../../ in the path to the file layer.
Comment 8 Halla Rempt 2018-02-27 13:20:48 UTC
Git commit 4e59102de741707c846ace7962e47993fac5566b by Boudewijn Rempt.
Committed on 27/02/2018 at 13:20.
Pushed by rempt into branch 'master'.

scripting: Temporarily set the saveAs url on the document

Otherwise the document might have an empty or wrong url and saving
file layers is broken. This doesn't fix 390853' hitting a safe_assert
in the KisDocument destructor, though.

M  +3    -1    libs/libkis/Document.cpp

https://commits.kde.org/krita/4e59102de741707c846ace7962e47993fac5566b
Comment 9 Halla Rempt 2018-02-27 13:48:05 UTC
Okay, now it seems to work fine for me. The only way to get an assert is now by closing krita, opening a document with a file layer and closing Krita; that's, howebver, not relevant to this bug.