Rekursionstiefen-Fehler
Diese Warnkategorie wird von qmllint mit [recursion-depth-errors]
angegeben.
Maximale Anweisungs- oder Ausdruckstiefe überschritten
Was ist passiert?
Eine QML-Anweisung oder ein Ausdruck war für den Compiler zu tief verschachtelt. Das passiert normalerweise nur bei generiertem Code, bei dem Anweisungen oder Ausdrücke sehr lang sein können, da die Rekursionsgrenze normalerweise groß genug für jedes vernünftige QML-Dokument ist.
Warum ist das schlecht?
Die QML-Engine wird nicht in der Lage sein, diesen Code auszuführen.
Beispiel
import QtQuick Item { function f() { let x = 1 + 1 + .... + 1 // maximum depth exceeded: add too many ones together return x } Item { Item { .... } } // maximum depth exceeded: too many nested Item's }
Um diese Warnung zu beheben, generieren Sie automatisch kleinere Codestücke. Teilen Sie tief verschachtelte Komponenten in mehrere Dateien oder Inline-Komponenten auf, oder teilen Sie tief verschachtelte Ausdrücke in mehrere Ausdrücke auf:
import QtQuick Item { function f() { let x = 1 + 1 + .... + 1 // first half of the split x += 1 + 1 + .... + 1 // second half of the split return x } component NestedItem : Item { Item {... }} // first half of the nested Item component DeeplyNestedItem: Item { ... NestedItem{} ... } // second half of the nested Items + NestedItem DeeplyNestedItem {} }
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.