aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-08-15 10:35:53 +0200
committerLars Knoll <lars.knoll@qt.io>2016-10-10 14:11:47 +0000
commit4ee2bc4e9c05d8daec8b04412a0b7c0264fbc1a4 (patch)
tree03b0dd07b6b087b5bdaded499961ee1492d408ae /src/qml/qml
parent11e0e5574a529e337e43ab15fca357b109ea2834 (diff)
Turn the no-network support into a configurable feature
Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlengine.cpp8
-rw-r--r--src/qml/qml/qqmlengine.h4
-rw-r--r--src/qml/qml/qqmlengine_p.h2
-rw-r--r--src/qml/qml/qqmlfile.cpp20
-rw-r--r--src/qml/qml/qqmlfile.h2
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp4
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.h4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp44
-rw-r--r--src/qml/qml/qqmltypeloader_p.h13
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp4
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h4
-rw-r--r--src/qml/qml/v8/qv8engine.cpp6
-rw-r--r--src/qml/qml/v8/qv8engine_p.h2
13 files changed, 60 insertions, 57 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index cb51c18925..c10aa0129c 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -70,7 +70,7 @@
#include <QtCore/qthread.h>
#include <private/qthread_p.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include "qqmlnetworkaccessmanagerfactory.h"
#include <QNetworkAccessManager>
#include <QtNetwork/qnetworkconfigmanager.h>
@@ -646,7 +646,7 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
cleanup(0), erroredBindings(0), inProgressCreations(0),
workerScriptEngine(0),
activeObjectCreator(0),
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
networkAccessManager(0), networkAccessManagerFactory(0),
#endif
urlInterceptor(0), scarceResourcesRefCount(0), importDatabase(e), typeLoader(e),
@@ -1129,7 +1129,7 @@ void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
}
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
Sets the \a factory to use for creating QNetworkAccessManager(s).
@@ -1196,7 +1196,7 @@ QNetworkAccessManager *QQmlEngine::networkAccessManager() const
Q_D(const QQmlEngine);
return d->getNetworkAccessManager();
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index bbb9c36ce9..2c0c39d0b4 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -87,7 +87,7 @@ class QQmlExpression;
class QQmlContext;
class QQmlType;
class QUrl;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
class QQmlNetworkAccessManagerFactory;
#endif
@@ -117,7 +117,7 @@ public:
bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *);
QQmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 713b03dbf3..916566b6c7 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -162,7 +162,7 @@ public:
void registerFinalizeCallback(QObject *obj, int index);
QQmlObjectCreator *activeObjectCreator;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index 4769402855..4e4db086b0 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -68,7 +68,7 @@ static char assets_string[] = "assets";
class QQmlFilePrivate;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QQmlFileNetworkReply : public QObject
{
Q_OBJECT
@@ -117,12 +117,12 @@ public:
Error error;
QString errorString;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QQmlFileNetworkReply *reply;
#endif
};
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
int QQmlFileNetworkReply::finishedIndex = -1;
int QQmlFileNetworkReply::downloadProgressIndex = -1;
int QQmlFileNetworkReply::networkFinishedIndex = -1;
@@ -205,11 +205,11 @@ void QQmlFileNetworkReply::networkDownloadProgress(qint64 a, qint64 b)
{
emit downloadProgress(a, b);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
QQmlFilePrivate::QQmlFilePrivate()
: error(None)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, reply(0)
#endif
{
@@ -233,7 +233,7 @@ QQmlFile::QQmlFile(QQmlEngine *e, const QString &url)
QQmlFile::~QQmlFile()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete d->reply;
#endif
delete d;
@@ -273,7 +273,7 @@ QQmlFile::Status QQmlFile::status() const
{
if (d->url.isEmpty() && d->urlString.isEmpty())
return Null;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
else if (d->reply)
return Loading;
#endif
@@ -333,7 +333,7 @@ void QQmlFile::load(QQmlEngine *engine, const QUrl &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
d->reply = new QQmlFileNetworkReply(engine, d, url);
#else
d->error = QQmlFilePrivate::NotFound;
@@ -364,7 +364,7 @@ void QQmlFile::load(QQmlEngine *engine, const QString &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QUrl qurl(url);
d->url = qurl;
d->urlString = QString();
@@ -388,7 +388,7 @@ void QQmlFile::clear(QObject *)
clear();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
bool QQmlFile::connectFinished(QObject *object, const char *method)
{
if (!d || !d->reply) {
diff --git a/src/qml/qml/qqmlfile.h b/src/qml/qml/qqmlfile.h
index 3dd683a2cd..aec0981a95 100644
--- a/src/qml/qml/qqmlfile.h
+++ b/src/qml/qml/qqmlfile.h
@@ -80,7 +80,7 @@ public:
void clear();
void clear(QObject *);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
bool connectFinished(QObject *, const char *);
bool connectFinished(QObject *, int);
bool connectDownloadProgress(QObject *, const char *);
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
index c94db8e168..1680253d73 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
@@ -41,7 +41,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
\class QQmlNetworkAccessManagerFactory
@@ -103,6 +103,6 @@ QQmlNetworkAccessManagerFactory::~QQmlNetworkAccessManagerFactory()
implementation of this method is reentrant.
*/
-#endif //QT_NO_NETWORK
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
index ba3561b9f4..57dec1da29 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
class Q_QML_EXPORT QQmlNetworkAccessManagerFactory
@@ -56,7 +56,7 @@ public:
};
-#endif //QT_NO_NETWORK
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 87100d785e..1f1c9d7150 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -123,7 +123,7 @@ namespace {
};
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// This is a lame object that we need to ensure that slots connected to
// QNetworkReply get called in the correct thread (the loader thread).
// As QQmlTypeLoader lives in the main thread, and we can't use
@@ -143,7 +143,7 @@ public slots:
private:
QQmlTypeLoader *l;
};
-#endif // QT_NO_NETWORK
+#endif // qml_network
class QQmlTypeLoaderThread : public QQmlThread
{
@@ -151,10 +151,10 @@ class QQmlTypeLoaderThread : public QQmlThread
public:
QQmlTypeLoaderThread(QQmlTypeLoader *loader);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager() const;
QQmlTypeLoaderNetworkReplyProxy *networkReplyProxy() const;
-#endif // QT_NO_NETWORK
+#endif // qml_network
void load(QQmlDataBlob *b);
void loadAsync(QQmlDataBlob *b);
void loadWithStaticData(QQmlDataBlob *b, const QByteArray &);
@@ -177,13 +177,13 @@ private:
void initializeEngineMain(QQmlExtensionInterface *iface, const char *uri);
QQmlTypeLoader *m_loader;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
mutable QNetworkAccessManager *m_networkAccessManager;
mutable QQmlTypeLoaderNetworkReplyProxy *m_networkReplyProxy;
-#endif // QT_NO_NETWORK
+#endif // qml_network
};
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QQmlTypeLoaderNetworkReplyProxy::QQmlTypeLoaderNetworkReplyProxy(QQmlTypeLoader *l)
: l(l)
{
@@ -212,7 +212,7 @@ void QQmlTypeLoaderNetworkReplyProxy::manualFinished(QNetworkReply *reply)
l->networkReplyProgress(reply, replySize, replySize);
l->networkReplyFinished(reply);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
\class QQmlDataBlob
@@ -529,7 +529,7 @@ void QQmlDataBlob::done()
{
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
Invoked if there is a network error while fetching this blob.
@@ -582,7 +582,7 @@ void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError)
setError(error);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
Called if \a blob, which was previously waited for, has an error.
@@ -782,15 +782,15 @@ void QQmlDataBlob::ThreadData::setProgress(quint8 v)
QQmlTypeLoaderThread::QQmlTypeLoaderThread(QQmlTypeLoader *loader)
: m_loader(loader)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, m_networkAccessManager(0), m_networkReplyProxy(0)
-#endif // QT_NO_NETWORK
+#endif // qml_network
{
// Do that after initializing all the members.
startup();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QQmlTypeLoaderThread::networkAccessManager() const
{
Q_ASSERT(isThisThread());
@@ -808,7 +808,7 @@ QQmlTypeLoaderNetworkReplyProxy *QQmlTypeLoaderThread::networkReplyProxy() const
Q_ASSERT(m_networkReplyProxy); // Must call networkAccessManager() first
return m_networkReplyProxy;
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
void QQmlTypeLoaderThread::load(QQmlDataBlob *b)
{
@@ -866,12 +866,12 @@ void QQmlTypeLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
void QQmlTypeLoaderThread::shutdownThread()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete m_networkAccessManager;
m_networkAccessManager = 0;
delete m_networkReplyProxy;
m_networkReplyProxy = 0;
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
void QQmlTypeLoaderThread::loadThread(QQmlDataBlob *b)
@@ -957,14 +957,14 @@ void QQmlTypeLoader::invalidate()
m_thread = 0;
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// Need to delete the network replies after
// the loader thread is shutdown as it could be
// getting new replies while we clear them
for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
(*iter)->release();
m_networkReplies.clear();
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
void QQmlTypeLoader::lock()
@@ -1138,7 +1138,7 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
setData(blob, fileName);
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(blob->m_url));
QQmlTypeLoaderNetworkReplyProxy *nrp = m_thread->networkReplyProxy();
blob->addref();
@@ -1156,14 +1156,14 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
#ifdef DATABLOB_DEBUG
qWarning("QQmlDataBlob: requested %s", qPrintable(blob->url().toString()));
#endif // DATABLOB_DEBUG
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
}
#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
#define TYPELOADER_MINIMUM_TRIM_THRESHOLD 64
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
{
Q_ASSERT(m_thread->isThisThread());
@@ -1219,7 +1219,7 @@ void QQmlTypeLoader::networkReplyProgress(QNetworkReply *reply,
m_thread->callDownloadProgressChanged(blob, blob->m_data.progress());
}
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
Return the QQmlEngine associated with this loader
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 5c779e450d..53cf4234e1 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -51,9 +51,10 @@
// We mean it.
//
+#include <QtQml/qtqmlglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qatomic.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkreply.h>
#endif
#include <QtQml/qqmlerror.h>
@@ -154,7 +155,7 @@ protected:
virtual void dataReceived(const Data &) = 0;
virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) = 0;
virtual void done();
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
virtual void networkError(QNetworkReply::NetworkError);
#endif
virtual void dependencyError(QQmlDataBlob *);
@@ -320,16 +321,16 @@ public:
private:
friend class QQmlDataBlob;
friend class QQmlTypeLoaderThread;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
friend class QQmlTypeLoaderNetworkReplyProxy;
-#endif // QT_NO_NETWORK
+#endif // qml_network
void shutdownThread();
void loadThread(QQmlDataBlob *);
void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void networkReplyFinished(QNetworkReply *);
void networkReplyProgress(QNetworkReply *, qint64, qint64);
@@ -366,7 +367,7 @@ private:
QQmlEngine *m_engine;
QQmlTypeLoaderThread *m_thread;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
NetworkReplies m_networkReplies;
#endif
TypeCache m_typeCache;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index f94946820f..10b1cbcfd4 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -70,7 +70,7 @@
using namespace QV4;
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
#define V4THROW_REFERENCE(string) { \
ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
@@ -2056,6 +2056,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
+#endif // QT_NO_XMLSTREAMREADER && qml_network
#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index df30873915..fdb6194537 100644
--- a/src/qml/qml/qqmlxmlhttprequest_p.h
+++ b/src/qml/qml/qqmlxmlhttprequest_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qglobal.h>
#include <private/qqmlglobal_p.h>
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
QT_BEGIN_NAMESPACE
@@ -64,7 +64,7 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *);
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
+#endif // QT_NO_XMLSTREAMREADER && qml_network
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index f15020f6c9..b0599dd0a2 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -160,8 +160,10 @@ QV8Engine::~QV8Engine()
qDeleteAll(m_extensionData);
m_extensionData.clear();
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = 0;
+#endif
delete m_listModelData;
m_listModelData = 0;
@@ -169,7 +171,7 @@ QV8Engine::~QV8Engine()
delete m_v4Engine;
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QV8Engine::networkAccessManager()
{
return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager();
@@ -193,7 +195,7 @@ void QV8Engine::initializeGlobal()
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
#endif
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 390831609b..0cbe34fd30 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -188,7 +188,7 @@ public:
void freezeObject(const QV4::Value &value);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// Return the network access manager for this engine. By default this returns the network
// access manager of the QQmlEngine. It is overridden in the case of a threaded v8
// instance (like in WorkerScript).