diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-12-08 15:48:17 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-09 10:07:19 +0100 |
commit | 3228864f7b9ea20f307beedd1fd7e56fb3216654 (patch) | |
tree | 3e5402c22c32a73411bc8a1ff72fdfced9f4efcf /src/qml/qml/qqmltypeloader_p.h | |
parent | 3adcf75c6c2585d643bd30a23da11912410f80d7 (diff) |
Cleanup: Merge QQmlDataLoader and QQmlTypeLoader
There exists only one sub-class of QQmlDataLoader and there are no virtual
functions.
This also clears up a confusion reported in Jira that suggested QQmlDataLoader
should get a virtual destructor as it is being subclassed and somebody might
have a pointer only to a QQmlDataLoader and deleting that would not do proper
polymorphic destruction.
Change-Id: I34611be5a95522bc85a87fb7df97b6d1de7a3d37
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'src/qml/qml/qqmltypeloader_p.h')
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 101 |
1 files changed, 46 insertions, 55 deletions
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 3b5aa1ec7a..fecb3c1764 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -73,7 +73,7 @@ class QQmlTypeLoader; class QQmlCompiledData; class QQmlComponentPrivate; class QQmlTypeData; -class QQmlDataLoader; +class QQmlTypeLoader; class QQmlExtensionInterface; namespace QmlIR { @@ -84,7 +84,7 @@ class Q_QML_PRIVATE_EXPORT QQmlDataBlob : public QQmlRefCount { public: enum Status { - Null, // Prior to QQmlDataLoader::load() + Null, // Prior to QQmlTypeLoader::load() Loading, // Prior to data being received and dataReceived() being called WaitingForDependencies, // While there are outstanding addDependency()s Complete, // Finished @@ -100,7 +100,7 @@ public: QQmlDataBlob(const QUrl &, Type); virtual ~QQmlDataBlob(); - void startLoading(QQmlDataLoader* manager); + void startLoading(QQmlTypeLoader* manager); Type type() const; @@ -132,7 +132,7 @@ public: private: friend class QQmlDataBlob; - friend class QQmlDataLoader; + friend class QQmlTypeLoader; inline Data(); Data(const Data &); Data &operator=(const Data &); @@ -158,8 +158,8 @@ protected: virtual void downloadProgressChanged(qreal); virtual void completed(); private: - friend class QQmlDataLoader; - friend class QQmlDataLoaderThread; + friend class QQmlTypeLoader; + friend class QQmlTypeLoaderThread; void tryDone(); void cancelAllWaitingFor(); @@ -199,59 +199,13 @@ private: QList<QQmlDataBlob *> m_waitingFor; // Manager that is currently fetching data for me - QQmlDataLoader *m_manager; + QQmlTypeLoader *m_manager; int m_redirectCount:30; bool m_inCallback:1; bool m_isDone:1; }; -class QQmlDataLoaderThread; -class QQmlDataLoader -{ -public: - QQmlDataLoader(QQmlEngine *); - ~QQmlDataLoader(); - - void lock(); - void unlock(); - - bool isConcurrent() const { return true; } - - enum Mode { PreferSynchronous, Asynchronous }; - - void load(QQmlDataBlob *, Mode = PreferSynchronous); - void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous); - void loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit, Mode mode = PreferSynchronous); - - QQmlEngine *engine() const; - void initializeEngine(QQmlExtensionInterface *, const char *); - void invalidate(); - -protected: - void shutdownThread(); - -private: - friend class QQmlDataBlob; - friend class QQmlDataLoaderThread; - friend class QQmlDataLoaderNetworkReplyProxy; - - void loadThread(QQmlDataBlob *); - void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &); - void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); - void networkReplyFinished(QNetworkReply *); - void networkReplyProgress(QNetworkReply *, qint64, qint64); - - typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies; - - void setData(QQmlDataBlob *, const QByteArray &); - void setData(QQmlDataBlob *, QQmlFile *); - void setData(QQmlDataBlob *, const QQmlDataBlob::Data &); - void setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); - - QQmlEngine *m_engine; - QQmlDataLoaderThread *m_thread; - NetworkReplies m_networkReplies; -}; +class QQmlTypeLoaderThread; class QQmlBundleData : public QQmlBundle, public QQmlRefCount @@ -261,10 +215,12 @@ public: QString fileName; }; -class Q_AUTOTEST_EXPORT QQmlTypeLoader : public QQmlDataLoader +class Q_AUTOTEST_EXPORT QQmlTypeLoader { Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader) public: + enum Mode { PreferSynchronous, Asynchronous }; + class Q_QML_PRIVATE_EXPORT Blob : public QQmlDataBlob { public: @@ -354,10 +310,42 @@ public: bool isTypeLoaded(const QUrl &url) const; bool isScriptLoaded(const QUrl &url) const; + void lock(); + void unlock(); + + bool isConcurrent() const { return true; } + + void load(QQmlDataBlob *, Mode = PreferSynchronous); + void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous); + void loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit, Mode mode = PreferSynchronous); + + QQmlEngine *engine() const; + void initializeEngine(QQmlExtensionInterface *, const char *); + void invalidate(); + private: + friend class QQmlDataBlob; + friend class QQmlTypeLoaderThread; + friend class QQmlTypeLoaderNetworkReplyProxy; + + void shutdownThread(); + void addBundleNoLock(const QString &, const QString &); QString bundleIdForQmldir(const QString &qmldir, const QString &uriHint); + void loadThread(QQmlDataBlob *); + void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &); + void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); + void networkReplyFinished(QNetworkReply *); + void networkReplyProgress(QNetworkReply *, qint64, qint64); + + typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies; + + void setData(QQmlDataBlob *, const QByteArray &); + void setData(QQmlDataBlob *, QQmlFile *); + void setData(QQmlDataBlob *, const QQmlDataBlob::Data &); + void setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); + template<typename T> struct TypedCallback { @@ -383,6 +371,9 @@ private: typedef QStringHash<QQmlBundleData *> BundleCache; typedef QStringHash<QString> QmldirBundleIdCache; + QQmlEngine *m_engine; + QQmlTypeLoaderThread *m_thread; + NetworkReplies m_networkReplies; TypeCache m_typeCache; ScriptCache m_scriptCache; QmldirCache m_qmldirCache; |