[Development] Reference cycles in QML

David McFarland corngood at gmail.com
Fri Aug 16 04:54:37 CEST 2013


I found that having dependency cycles in QML components causes the
typeloader to get stuck with all blobs in a loading state (i.e. no useful
diagnostics).  This can be caused by something like this:

A.qml
--------
QtObject {
    property B foo
}
--------
B.qml:
--------
QtObject {
    property A foo
}
--------

or

A.qml
--------
QtObject {
    property Component foo: B {}
}
--------
B.qml:
--------
QtObject {
    property Component foo: A {}
}
--------

I couldn't find any discussion of this in the archives, so I started
experimenting.

I've attached a patch of my current progress, which will allow the above
cases to succeed.  I wouldn't consider it ready to commit, as I wrote it
incrementally while learning the systems, so it's a bit messy.  It could
easily have some bad side-effects, but it does work without any obvious
problems in a fairly complex project (game), using Layouts, Controls, a
couple of my own plugins, etc.

I haven't even run it on any of the examples/tests yet, which obviously
should be done, but I wanted to see if anyone had any plans to deal with
this problem (or reasons not to).

Here's roughly what the patch does:

- detects cycles of blobs typeloader who are all waiting on dependencies,
and forces them to complete
- allows compilation of type data to trigger compliation of other type data
- allows type data compilation to happen in two passes, so that the root
component can be built without building all components
- creates synthesised types earlier so that they are available when there's
a dependency cycle (e.g. through a property)

Again, the patch definitely needs cleaning up.  I just made it to learn the
system and prove to myself that there were no obvious roadblocks to fixing
this.

I'll carry on testing it, and look forward to hearing your feedback.

Cheers,
Dave McFarland
[Guy who tinkers with Qt in his time off from coding games (sigh)]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130815/dc87814b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qmlcycles.patch
Type: application/octet-stream
Size: 35888 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130815/dc87814b/attachment.obj>


More information about the Development mailing list