diff options
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 38 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 15 |
3 files changed, 26 insertions, 31 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 20bc28d886..86b60cb73a 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -667,11 +667,7 @@ bool QQmlImportNamespace::Import::resolveType(QQmlTypeLoader *typeLoader, }; for (uint i = 0; i < sizeof(urlsToTry) / sizeof(urlsToTry[0]); ++i) { const QString url = urlsToTry[i]; - exists = !typeLoader->absoluteFilePath(QQmlFile::urlToLocalFileOrQrc(url)).isEmpty(); - if (!exists) - exists = QQmlMetaType::findCachedCompilationUnit(QUrl(url)); - if (exists) { qmlUrl = url; break; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 7f4161494a..0c917ff90b 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -234,10 +234,14 @@ This enum describes the type of the data blob. /*! Create a new QQmlDataBlob for \a url and of the provided \a type. */ -QQmlDataBlob::QQmlDataBlob(const QUrl &url, Type type) -: m_type(type), m_url(url), m_finalUrl(url), m_manager(0), m_redirectCount(0), +QQmlDataBlob::QQmlDataBlob(const QUrl &url, Type type, QQmlTypeLoader *manager) +: m_typeLoader(manager), m_type(type), m_url(url), m_finalUrl(url), m_redirectCount(0), m_inCallback(false), m_isDone(false) { + //Set here because we need to get the engine from the manager + if (m_typeLoader->engine() && m_typeLoader->engine()->urlInterceptor()) + m_url = m_typeLoader->engine()->urlInterceptor()->intercept(m_url, + (QQmlAbstractUrlInterceptor::DataType)m_type); } /*! \internal */ @@ -249,20 +253,12 @@ QQmlDataBlob::~QQmlDataBlob() } /*! - Sets the manager, and does stuff like selection which needs access to the manager. Must be called before loading can occur. */ -void QQmlDataBlob::startLoading(QQmlTypeLoader *manager) +void QQmlDataBlob::startLoading() { Q_ASSERT(status() == QQmlDataBlob::Null); - Q_ASSERT(m_manager == 0); m_data.setStatus(QQmlDataBlob::Loading); - m_manager = manager; - - //Set here because we need to get the engine from the manager - if (manager && manager->engine() && manager->engine()->urlInterceptor()) - m_url = manager->engine()->urlInterceptor()->intercept(m_url, - (QQmlAbstractUrlInterceptor::DataType)m_type); } /*! @@ -360,7 +356,7 @@ May only be called from the load thread, or after the blob isCompleteOrError(). */ QUrl QQmlDataBlob::finalUrl() const { - Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread())); + Q_ASSERT(isCompleteOrError() || (m_typeLoader && m_typeLoader->m_thread->isThisThread())); return m_finalUrl; } @@ -369,7 +365,7 @@ Returns the finalUrl() as a string. */ QString QQmlDataBlob::finalUrlString() const { - Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread())); + Q_ASSERT(isCompleteOrError() || (m_typeLoader && m_typeLoader->m_thread->isThisThread())); if (m_finalUrlString.isEmpty()) m_finalUrlString = m_finalUrl.toString(); @@ -383,7 +379,7 @@ May only be called from the load thread, or after the blob isCompleteOrError(). */ QList<QQmlError> QQmlDataBlob::errors() const { - Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread())); + Q_ASSERT(isCompleteOrError() || (m_typeLoader && m_typeLoader->m_thread->isThisThread())); return m_errors; } @@ -617,7 +613,7 @@ void QQmlDataBlob::tryDone() #ifdef DATABLOB_DEBUG qWarning("QQmlDataBlob: Dispatching completed"); #endif - m_manager->m_thread->callCompleted(this); + m_typeLoader->m_thread->callCompleted(this); release(); } @@ -921,7 +917,7 @@ void QQmlTypeLoader::load(QQmlDataBlob *blob, Mode mode) qWarning("QQmlTypeLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()), m_thread->isThisThread()?"Compile":"Engine"); #endif - blob->startLoading(this); + blob->startLoading(); if (m_thread->isThisThread()) { unlock(); @@ -954,7 +950,7 @@ void QQmlTypeLoader::loadWithStaticData(QQmlDataBlob *blob, const QByteArray &da m_thread->isThisThread()?"Compile":"Engine"); #endif - blob->startLoading(this); + blob->startLoading(); if (m_thread->isThisThread()) { unlock(); @@ -982,7 +978,7 @@ void QQmlTypeLoader::loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::C m_thread->isThisThread()?"Compile":"Engine"); #endif - blob->startLoading(this); + blob->startLoading(); if (m_thread->isThisThread()) { unlock(); @@ -1235,7 +1231,7 @@ void QQmlTypeLoader::shutdownThread() } QQmlTypeLoader::Blob::Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader) - : QQmlDataBlob(url, type), m_typeLoader(loader), m_importCache(loader), m_isSingleton(false) + : QQmlDataBlob(url, type, loader), m_importCache(loader), m_isSingleton(false) { } @@ -1608,7 +1604,7 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) typeData = new QQmlTypeData(url, this); // TODO: if (compiledData == 0), is it safe to omit this insertion? m_typeCache.insert(url, typeData); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) { + if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(typeData->url())) { QQmlTypeLoader::loadWithCachedUnit(typeData, cachedUnit, mode); } else { QQmlTypeLoader::load(typeData, mode); @@ -1651,7 +1647,7 @@ QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &url) scriptBlob = new QQmlScriptBlob(url, this); m_scriptCache.insert(url, scriptBlob); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) { + if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(scriptBlob->url())) { QQmlTypeLoader::loadWithCachedUnit(scriptBlob, cachedUnit); } else { QQmlTypeLoader::load(scriptBlob); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 64e3937a74..f5c15d0513 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -96,10 +96,12 @@ public: QmldirFile = QQmlAbstractUrlInterceptor::QmldirFile }; - QQmlDataBlob(const QUrl &, Type); + QQmlDataBlob(const QUrl &, Type, QQmlTypeLoader* manager); virtual ~QQmlDataBlob(); - void startLoading(QQmlTypeLoader* manager); + void startLoading(); + + QQmlTypeLoader *typeLoader() const { return m_typeLoader; } Type type() const; @@ -156,6 +158,11 @@ protected: // Callbacks made in main thread virtual void downloadProgressChanged(qreal); virtual void completed(); + +protected: + // Manager that is currently fetching data for me + QQmlTypeLoader *m_typeLoader; + private: friend class QQmlTypeLoader; friend class QQmlTypeLoaderThread; @@ -197,8 +204,6 @@ private: // List of QQmlDataBlob's that I am waiting for to complete. QList<QQmlDataBlob *> m_waitingFor; - // Manager that is currently fetching data for me - QQmlTypeLoader *m_manager; int m_redirectCount:30; bool m_inCallback:1; bool m_isDone:1; @@ -218,7 +223,6 @@ public: Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader); ~Blob(); - QQmlTypeLoader *typeLoader() const { return m_typeLoader; } const QQmlImports &imports() const { return m_importCache; } protected: @@ -239,7 +243,6 @@ public: protected: virtual QString stringAt(int) const { return QString(); } - QQmlTypeLoader *m_typeLoader; QQmlImports m_importCache; bool m_isSingleton; QHash<const QV4::CompiledData::Import*, int> m_unresolvedImports; |