Fix infinite loop in QQmlIncubator::forceCompletion

Without this change I'm getting this backtrace
3  0x4025b9f2 in QQmlIncubatorPrivate::incubate (this=0x18daa78, i=...) at qml/qqmlincubator.cpp:273
4  0x4025c1c2 in QQmlIncubator::forceCompletion (this=0x1527360) at qml/qqmlincubator.cpp:592
5  0x404e1626 in QQuickVisualDataModelPrivate::object (this=this@entry=0x13909f8, group=QQuickListCompositor::Default, index=index@entry=1, asynchronous=asynchronous@entry=false) at items/qquickvisualdatamodel.cpp:900
6  0x404e1f7e in QQuickVisualDataModel::item (this=<optimized out>, index=1, asynchronous=<optimized out>) at items/qquickvisualdatamodel.cpp:968
Note: This is with patched 5.0.x, change QQuickVisualDataModel to QQmlDelegateModel for >= 5.1
      and line numbers may be a bit off

What is happening:
QQmlIncubator::forceCompletion is doing
    while (Loading == status()) {
        while (Loading == status() && !d->waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(d->waitingFor.first())->incubate(i);
        if (Loading == status())
            d->incubate(i);
    }
Calling QQmlIncubatorPrivate::incubate on the first item of d->waitingFor

Then, that item is getting to QQmlIncubatorPrivate::incubate and happens that
progress is QQmlIncubatorPrivate::Completed and waitingFor is not empty,
so the only thing that QQmlIncubatorPrivate::incubate ends up doing is
calling a few calls over vmeGuard and returning, that way the inner
waitingFor items never finishe incubating and you end up in an inifite loop inside
        while (Loading == status() && !d->waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(d->waitingFor.first())->incubate(i);

This patch basically replaces this loop with a loop that does
        while (QQmlIncubator::Loading == status && !waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(waitingFor.first())->forceCompletion(i);

This way we make sure we incubate the waitingFor items of our waitingFor items

Change-Id: I4298efc7ba9d8af624bb138e64b92a40ed4c4dc9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Merge pull request #59 from special/qqmlincubator-loop

[qtdeclarative] Fix infinite loop in QQmlIncubator::forceCompletion
Merge pull request #60 from sletta/master

[qtdeclarative] Make sure the visibility state is the same in GUI and Render threads.
[qtdeclarative] Avoid reentrancy issues with QQmlVME.

Change-Id: I6cf894a6e693c4c586032808c09ed34220dbdb7b