diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-01-21 01:39:28 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2011-01-21 01:40:47 (GMT) |
commit | 8c3086aa36b51a9731fce8eb8146b33ab8196aed (patch) | |
tree | ba7cb057f4182942a82a1ed173b5aa7551254e3d /src/declarative/graphicsitems/qdeclarativeloader.cpp | |
parent | 4cf56db73dc36d230215855398b37bd0c634c099 (diff) | |
download | Qt-8c3086aa36b51a9731fce8eb8146b33ab8196aed.zip Qt-8c3086aa36b51a9731fce8eb8146b33ab8196aed.tar.gz Qt-8c3086aa36b51a9731fce8eb8146b33ab8196aed.tar.bz2 |
Revert "Fix loaded() signal to be emitted only once"
This reverts commit 82ff3f484c7ec49e60b7fddf23794937974a6768.
QTBUG-16796 reports that this commit is causing regressions
relating to initial sizing of items.
Task-number: QTBUG-16796
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeloader.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeloader.cpp | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 86e438f..ded2be3 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE QDeclarativeLoaderPrivate::QDeclarativeLoaderPrivate() - : item(0), component(0), ownComponent(false), isComponentComplete(false) + : item(0), component(0), ownComponent(false) { } @@ -262,7 +262,6 @@ void QDeclarativeLoader::setSource(const QUrl &url) d->clear(); d->source = url; - if (d->source.isEmpty()) { emit sourceChanged(); emit statusChanged(); @@ -273,9 +272,18 @@ void QDeclarativeLoader::setSource(const QUrl &url) d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this); d->ownComponent = true; - - if (d->isComponentComplete) - d->load(); + if (!d->component->isLoading()) { + d->_q_sourceLoaded(); + } else { + connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), + this, SLOT(_q_sourceLoaded())); + connect(d->component, SIGNAL(progressChanged(qreal)), + this, SIGNAL(progressChanged())); + emit statusChanged(); + emit progressChanged(); + emit sourceChanged(); + emit itemChanged(); + } } /*! @@ -316,7 +324,6 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp) d->component = comp; d->ownComponent = false; - if (!d->component) { emit sourceChanged(); emit statusChanged(); @@ -325,8 +332,18 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp) return; } - if (d->isComponentComplete) - d->load(); + if (!d->component->isLoading()) { + d->_q_sourceLoaded(); + } else { + connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), + this, SLOT(_q_sourceLoaded())); + connect(d->component, SIGNAL(progressChanged(qreal)), + this, SIGNAL(progressChanged())); + emit progressChanged(); + emit sourceChanged(); + emit statusChanged(); + emit itemChanged(); + } } void QDeclarativeLoader::resetSourceComponent() @@ -334,27 +351,6 @@ void QDeclarativeLoader::resetSourceComponent() setSourceComponent(0); } -void QDeclarativeLoaderPrivate::load() -{ - Q_Q(QDeclarativeLoader); - - if (!isComponentComplete || !component) - return; - - if (!component->isLoading()) { - _q_sourceLoaded(); - } else { - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), - q, SLOT(_q_sourceLoaded())); - QObject::connect(component, SIGNAL(progressChanged(qreal)), - q, SIGNAL(progressChanged())); - emit q->statusChanged(); - emit q->progressChanged(); - emit q->sourceChanged(); - emit q->itemChanged(); - } -} - void QDeclarativeLoaderPrivate::_q_sourceLoaded() { Q_Q(QDeclarativeLoader); @@ -469,11 +465,9 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const void QDeclarativeLoader::componentComplete() { - Q_D(QDeclarativeLoader); - QDeclarativeItem::componentComplete(); - d->isComponentComplete = true; - d->load(); + if (status() == Ready) + emit loaded(); } |