1

I updated my QML application from Qt 5.12 to Qt 5.15.

My application loads its qml sources using the following code:

auto* engine = new QQmlApplicationEngine(this);
...
engine->load(QUrl("qrc:/main.qml"));

When engine->load is called, I now get the following warning, which was not there with Qt 5.12:

Qt Quick Layouts: Detected recursive rearrange. Aborting after two iterations.

How can I find the source of this warning so I can fix my code?

Edit:

After two downvotes, I would like to clarify the intent of my question.

I have a very large application which is loading a big tree of qml files, with main.qml being the main Window. The warning that I posted comes from the Application output pane, without any hint to a source file location that caused the warning.

I am looking for a way to find the source file location that caused this kind of warning. I believe it is reasonable to ask how to achieve that, and I believe that this is a generic problem that will come up for many people who update their qml code to Qt 5.15. It's in the nature of such a issue that a self-contained example (like asked for in the comments) cannot be provided.

FourtyTwo
  • 1,616
  • 2
  • 15
  • 43
  • please provide [mcve] otherwise it seems impossible to solve the problem without seeing the code. – folibis Jul 16 '20 at 06:25
  • I think you'll have to go the long way, commenting out parts of the QML and trying in a recursive fashion. You can probably limit yourself to `RowLayout`, `ColumnLayout` and `GridLayout`'s – Amfasis Jul 16 '20 at 06:26
  • 1
    @folibis You would be right if this warning came with a related resource file location. It does not. This is just a one-line entry in the application output, without any hint where the source code is that is causing this. This makes it very hard to track down the source of the error, and I am looking for a way to track down the error. I'll edit the post to make this more clear. – FourtyTwo Jul 16 '20 at 08:54
  • It's reasonable to request more code so that the community can help in finding the culprit. If you project is too big to post, you can only expect help at a very low level. Also, I would not expect anyone to go dig through a big project where I can do it myself, in the way I described in my other comment. Furthrmore, I could not find any reference to the provided log message in the Qt codebase. Are you perhaps using any other imports as well? – Amfasis Jul 16 '20 at 10:08
  • @Amfasis I mostly agree with you. And of course I don't want anyone to dig through my big project. I was thinking that there must be an easier way than the "long way" you mentioned above, and I was thinking that if there is an easier way, it might be interesting for more people than just me - that's why I posted this here. The warning comes from this line here in the Qt codebase: https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/imports/layouts/qquicklinearlayout.cpp?h=5.15.0#n478 and it seems that it will not be part of Qt 5.15.1 - which is probably why you didn'T find it ... – FourtyTwo Jul 16 '20 at 11:20
  • @FourtyTwo agreed with posting for the interest of others! You did find yourself one more hint towards finding the culprit: it must be a `GridLayout`. I also wonder if it would be possible to add more logging in that function you found, like the object pointer or ultimately the qml location (I read that somewhere, but can't find it). Another option would be to add `console.log` to every `GridLayout` you have (use some find-and-replace skills) – Amfasis Jul 16 '20 at 11:46

1 Answers1

2

It's a totally reasonable ask - the warning is ambiguous so you'd have to post the entire codebase to get a minimum viable. Afaik there is no reasonable way to locate the offending bits programmatically but look for Layout components (RowLayout, ColumnLayout, GridLayout) nested inside the same kind of Layout component; these are the usual offenders. For instance:

ColumnLayout {

    ColumnLayout {
        id: childColumnLayout

        // this is generally the cause of your grief
        // changing the the child ColumnLayout to a Column usually fixes it for me

    }
}
lesley
  • 21
  • 2