Bug 497346 - recursively creating duplicate frames in groups causes crash.
Summary: recursively creating duplicate frames in groups causes crash.
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 5.2.6
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-12 01:10 UTC by G
Modified: 2024-12-13 03:46 UTC (History)
2 users (show)

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


Attachments
This is the script (1.76 KB, text/x-python)
2024-12-12 01:10 UTC, G
Details

Note You need to log in before you can comment on or make changes to this bug.
Description G 2024-12-12 01:10:18 UTC
Created attachment 176540 [details]
This is the script

SUMMARY
Using a custom script to create duplicate frames for all paint layers in a complicated group layer causes krita to crash. Krita spits out 'ASSERT (krita): "row >= 0" in file /builds/graphics/krita/plugins/dockers/animation/KisAnimCurvesChannelsModel.cpp, line 181' in the terminal, and then quits. 

This is the script I am using, and running through the script editor:
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QPushButton, QLineEdit, QLabel

global isTextDifferent
isTextDifferent=True


application = Krita.instance()
currentDoc = application.activeDocument()




def groupDuplicate():
    global isTextDifferent
    global currentDoc
    global application
    if(isTextDifferent):
        
        layers = currentDoc.nodeByName(text.text())
        
        if(text.text()==""):
            layers = currentDoc.activeNode()
        
        
        if(layers == None):
            print('layer does not exist!')
            return
        elif(str(type(layers)) != "<class 'PyKrita.krita.GroupLayer'>"):
            print('Not a group layer!')
            return
        GroupDuplicateLayer(layers.childNodes())
        isTextDifferent = False
    return
 
def GroupDuplicateLayer(layers):
    for layer in layers:
        print(layer)
        if(str(type(layer)) == "<class 'PyKrita.krita.Node'>"):
            layer.enableAnimation()
            global currentDoc
            currentDoc.setActiveNode(layer)
            Krita.instance().action('add_duplicate_frame').trigger()
        else:
            GroupDuplicateLayer(layer.childNodes())
   
    
    
def textChanged(x):
    global isTextDifferent
    isTextDifferent = True
    
# add button and layout for button
layout = QHBoxLayout()
newButton = QPushButton("Enter") 
text = QLineEdit()
label = QLabel("Update which group layer?")

layout.addWidget(label)
layout.addWidget(text)
layout.addWidget(newButton)

newButton.clicked.connect(groupDuplicate)
text.returnPressed.connect(groupDuplicate)
text.textEdited.connect(textChanged)

# create dialog  and show it
newDialog = QDialog() 
newDialog.setLayout(layout)
newDialog.setWindowTitle("New Dialog Title!") 
newDialog.exec_() # show the dialog

    

STEPS TO REPRODUCE
1. create a new image
2.  add several recursive group layers with paint layers inside them
3.  run the script above.

OBSERVED RESULT
It crashes.

EXPECTED RESULT
all the child paint layers to have a duplicate frame at the current frame number.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
I am using the appimage on Arch.
Comment 1 Dmitry Kazakov 2024-12-12 06:39:25 UTC
Hi, G!

Could you please test the latest Krita Plus build?

https://cdn.kde.org/ci-builds/graphics/krita/krita-5.2/

I guess I have fixed an issue like that quite recently during the bughunt month :)
Comment 2 G 2024-12-12 19:10:28 UTC
(In reply to Dmitry Kazakov from comment #1)
> Hi, G!
> 
> Could you please test the latest Krita Plus build?
> 
> https://cdn.kde.org/ci-builds/graphics/krita/krita-5.2/
> 
> I guess I have fixed an issue like that quite recently during the bughunt
> month :)

Unfortunately, the exact same bug occurred. It did crash a *bit* better--It actually had an error popup instead of just leaving the error in the terminal.
Comment 3 Bug Janitor Service 2024-12-13 03:46:54 UTC
🐛🧹 Thanks for your comment!

Automatically switching the status to REPORTED so the team can perform further triage.

In the future you may also do this yourself when providing needed information.