https://bugs.kde.org/show_bug.cgi?id=446811
Bug ID: 446811 Summary: setChildNodes misorders nodes, and a crash-bug on the way Product: krita Version: 5.0.0-beta2 Platform: Microsoft Windows OS: Microsoft Windows Status: REPORTED Severity: normal Priority: NOR Component: Layer Stack Assignee: krita-bugs-n...@kde.org Reporter: julesletters+...@gmail.com Target Milestone: --- Created attachment 144441 --> https://bugs.kde.org/attachment.cgi?id=144441&action=edit Long Crashlog included for completeness. The last few entries are from the provided script. SUMMARY STEPS TO REPRODUCE 1. Open Krita 2. Create a new document (I've used a custom document, 600 x 800) 3. Open the scripter via Tools > Scripts > Scripter, and use the following: ``` from krita import Krita, Document class MyBug: @staticmethod def log_info(text: str) -> None: print(text) @staticmethod def remove_layer_if_exists(document: Document, layer_name: str) -> None: layer = document.nodeByName(layer_name) if layer: layer.remove() def do_a_thing(self) -> None: self.log_info("Doing the thing!") active_document = Krita.instance().activeDocument() temp_layer_name = "MY_LAYER" cloned_layer_name = f"{temp_layer_name}_CLONE" if active_document: self.log_info("A") self.remove_layer_if_exists(active_document, temp_layer_name) self.remove_layer_if_exists(active_document, cloned_layer_name) self.log_info("B") temp_layer = active_document.createGroupLayer(temp_layer_name) self.log_info("C") active_document.rootNode().addChildNode(temp_layer, None) self.log_info("D") child_nodes = [active_document.createNode("01", "paintLayer"), active_document.createNode("02", "paintLayer"), active_document.createNode("03", "paintLayer")] self.log_info("E") temp_layer.setChildNodes(child_nodes) self.log_info("F") cloned_layer = temp_layer.clone() self.log_info("G") cloned_layer.setName(cloned_layer_name) additional_child_nodes = [active_document.createNode("04", "paintLayer"), active_document.createNode("05", "paintLayer")] nodes = cloned_layer.childNodes() + additional_child_nodes self.log_info(str([n.name() for n in nodes])) self.log_info("H") cloned_layer.setChildNodes(nodes) self.log_info("I") active_document.rootNode().addChildNode(cloned_layer, None) self.log_info("Exiting Doing the thing function.") MyBug().do_a_thing() ``` OBSERVED RESULT Either: 1) A Crash after 'C' is logged to the console 2) The resulting Node tree is: MY_LAYER_CLONE (05, 04, 01, 03, 02), MY_LAYER (03, 02, 01) EXPECTED RESULT The resulting Node tree is: MY_LAYER_CLONE (05, 04, 03, 02, 01), MY_LAYER (03, 02, 01) SOFTWARE/OS VERSIONS Windows: 10.0.19043 Build 19043.1348 KDE Plasma Version: ??? KDE Frameworks Version: ??? Qt Version: ??? -- You are receiving this mail because: You are watching all bug changes.