diff options
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r-- | src/quick/items/qquickloader.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp index da04a2956c..15cf20ea7a 100644 --- a/src/quick/items/qquickloader.cpp +++ b/src/quick/items/qquickloader.cpp @@ -161,9 +161,7 @@ qreal QQuickLoaderPrivate::getImplicitHeight() const \section2 Loader Sizing Behavior - If the source component is not an Item type, Loader does not - apply any special sizing rules. When used to load visual types, - Loader applies the following sizing rules: + When used to load visual types, Loader applies the following sizing rules: \list \li If an explicit size is not specified for the Loader, the Loader @@ -190,6 +188,8 @@ qreal QQuickLoaderPrivate::getImplicitHeight() const \li The red rectangle will be 50x50, centered in the root item. \endtable + If the source component is not an Item type, Loader does not apply any + special sizing rules. \section2 Receiving Signals from Loaded Objects @@ -673,13 +673,6 @@ void QQuickLoaderPrivate::incubatorStateChanged(QQmlIncubator::Status status) if (status == QQmlIncubator::Ready) { object = incubator->object(); item = qmlobject_cast<QQuickItem*>(object); - if (!item) { - QQuickWindow *window = qmlobject_cast<QQuickWindow*>(object); - if (window) { - qCDebug(lcTransient) << window << "is transient for" << q->window(); - window->setTransientParent(q->window()); - } - } emit q->itemChanged(); initResize(); incubator->clear(); @@ -795,7 +788,7 @@ void QQuickLoader::componentComplete() { Q_D(QQuickLoader); QQuickItem::componentComplete(); - if (active()) { + if (active() && (status() != Ready)) { if (d->loadingFromSource) d->createComponent(); d->load(); @@ -804,12 +797,15 @@ void QQuickLoader::componentComplete() void QQuickLoader::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) { - if (change == ItemSceneChange) { - QQuickWindow *loadedWindow = qmlobject_cast<QQuickWindow *>(item()); - if (loadedWindow) { - qCDebug(lcTransient) << loadedWindow << "is transient for" << value.window; - loadedWindow->setTransientParent(value.window); - } + switch (change) { + case ItemChildAddedChange: + Q_ASSERT(value.item); + if (value.item->flags().testFlag(QQuickItem::ItemObservesViewport)) + // Re-trigger the parent traversal to get subtreeTransformChangedEnabled turned on + value.item->setFlag(QQuickItem::ItemObservesViewport); + break; + default: + break; } QQuickItem::itemChange(change, value); } @@ -915,12 +911,24 @@ void QQuickLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) const bool needToUpdateWidth = loaderGeometryChanged && q->widthValid(); const bool needToUpdateHeight = loaderGeometryChanged && q->heightValid(); - if (needToUpdateWidth && needToUpdateHeight) + if (needToUpdateWidth && needToUpdateHeight) { + /* setSize keeps bindings intact (for backwards compatibility reasons), + but here we actually want the loader to control the size, so any + prexisting bindings ought to be removed + */ + auto *itemPriv = QQuickItemPrivate::get(item); + // takeBinding would work without the check, but this is more efficient + // for the common case where we don't have a binding + if (itemPriv->width.hasBinding()) + itemPriv->width.takeBinding(); + if (itemPriv->height.hasBinding()) + itemPriv->height.takeBinding(); item->setSize(QSizeF(q->width(), q->height())); - else if (needToUpdateWidth) + } else if (needToUpdateWidth) { item->setWidth(q->width()); - else if (needToUpdateHeight) + } else if (needToUpdateHeight) { item->setHeight(q->height()); + } if (updatingSize) return; |