aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-02-16 17:40:12 +0100
committerPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-03-04 13:09:51 +0000
commitc7ac28fa354b96de37dc6cde5e3728da8daaacbb (patch)
treeba34e8d5e14700a5e786ffbc78204e436cabf2e9
parent9456832163d3476e8f81440dd2978092a9000b72 (diff)
QtLite: no_network option for QtDeclarative
This patch adds the support for a no_network option for QtDeclarative, and the necessary #ifndef all around the code. no_network changes the interface of some classes, therefore using it breaks source compatibility. Change-Id: Iff612fb07041b8a7db99bd595bf038efaac2dd8a Reviewed-by: Risto Avila <risto.avila@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--examples/qml/qml.pro12
-rw-r--r--src/plugins/qmltooling/qmltooling.pro44
-rw-r--r--src/qml/jsruntime/qv4include.cpp38
-rw-r--r--src/qml/jsruntime/qv4include_p.h11
-rw-r--r--src/qml/qml.pro8
-rw-r--r--src/qml/qml/qqmlengine.cpp38
-rw-r--r--src/qml/qml/qqmlengine.h4
-rw-r--r--src/qml/qml/qqmlengine_p.h4
-rw-r--r--src/qml/qml/qqmlfile.cpp27
-rw-r--r--src/qml/qml/qqmlfile.h2
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp4
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.h3
-rw-r--r--src/qml/qml/qqmltypeloader.cpp32
-rw-r--r--src/qml/qml/qqmltypeloader_p.h10
-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
-rw-r--r--src/qml/types/qquickworkerscript.cpp18
-rw-r--r--src/quick/items/qquickanimatedimage.cpp11
-rw-r--r--src/quick/items/qquickanimatedimage_p_p.h11
-rw-r--r--src/quick/items/qquickborderimage.cpp10
-rw-r--r--src/quick/items/qquickborderimage_p.h2
-rw-r--r--src/quick/items/qquickborderimage_p_p.h19
-rw-r--r--src/quick/quick.pro7
-rw-r--r--src/quick/util/qquickfontloader.cpp37
-rw-r--r--src/quick/util/qquickpixmapcache.cpp43
27 files changed, 315 insertions, 96 deletions
diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro
index d5f9fa8a9e..3cb601f542 100644
--- a/examples/qml/qml.pro
+++ b/examples/qml/qml.pro
@@ -1,9 +1,13 @@
TEMPLATE = subdirs
-qtHaveModule(quick): SUBDIRS += \
- networkaccessmanagerfactory \
- qmlextensionplugins \
- xmlhttprequest
+qtHaveModule(quick) {
+ SUBDIRS += \
+ qmlextensionplugins \
+ xmlhttprequest
+
+ !no_network: SUBDIRS += \
+ networkaccessmanagerfactory
+}
SUBDIRS += \
referenceexamples \
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 3728126dd9..7682e7b075 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -1,30 +1,32 @@
TEMPLATE = subdirs
-# Utilities
-SUBDIRS += \
- packetprotocol
+!no_network {
+ # Utilities
+ SUBDIRS += \
+ packetprotocol
-# Connectors
-SUBDIRS += \
- qmldbg_native \
- qmldbg_server \
+ # Connectors
+ SUBDIRS += \
+ qmldbg_native \
+ qmldbg_server \
qmldbg_local \
qmldbg_tcp
-# Services
-SUBDIRS += \
- qmldbg_debugger \
- qmldbg_profiler
+ # Services
+ SUBDIRS += \
+ qmldbg_debugger \
+ qmldbg_profiler
-qmldbg_server.depends = packetprotocol
-qmldbg_native.depends = packetprotocol
-qmldbg_debugger.depends = packetprotocol
-qmldbg_profiler.depends = packetprotocol
+ qmldbg_server.depends = packetprotocol
+ qmldbg_native.depends = packetprotocol
+ qmldbg_debugger.depends = packetprotocol
+ qmldbg_profiler.depends = packetprotocol
-qtHaveModule(quick) {
- SUBDIRS += \
- qmldbg_inspector \
- qmldbg_quickprofiler
- qmldbg_inspector.depends = packetprotocol
- qmldbg_quickprofiler.depends = packetprotocol
+ qtHaveModule(quick) {
+ SUBDIRS += \
+ qmldbg_inspector \
+ qmldbg_quickprofiler
+ qmldbg_inspector.depends = packetprotocol
+ qmldbg_quickprofiler.depends = packetprotocol
+ }
}
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index 29f83da522..b3462fe9b1 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -41,8 +41,10 @@
#include "qv4scopedvalue_p.h"
#include <QtQml/qjsengine.h>
+#ifndef QT_NO_NETWORK
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
+#endif
#include <QtCore/qfile.h>
#include <QtQml/qqmlfile.h>
@@ -57,7 +59,10 @@ QT_BEGIN_NAMESPACE
QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
QV4::QmlContext *qmlContext, const QV4::Value &callback)
- : v4(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0)
+ : v4(engine), m_url(url)
+#ifndef QT_NO_NETWORK
+ , m_redirectCount(0), m_network(0) , m_reply(0)
+#endif
{
if (qmlContext)
m_qmlContext.set(engine, *qmlContext);
@@ -66,6 +71,7 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
m_resultObject.set(v4, resultValue(v4));
+#ifndef QT_NO_NETWORK
m_network = engine->v8Engine->networkAccessManager();
QNetworkRequest request;
@@ -73,11 +79,17 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
m_reply = m_network->get(request);
QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
+#else
+ finished();
+#endif
}
QV4Include::~QV4Include()
{
- delete m_reply; m_reply = 0;
+#ifndef QT_NO_NETWORK
+ delete m_reply;
+ m_reply = 0;
+#endif
}
QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status status)
@@ -123,6 +135,7 @@ QV4::ReturnedValue QV4Include::result()
#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15
void QV4Include::finished()
{
+#ifndef QT_NO_NETWORK
m_redirectCount++;
if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) {
@@ -166,6 +179,12 @@ void QV4Include::finished()
} else {
resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
}
+#else
+ QV4::Scope scope(v4);
+ QV4::ScopedObject resultObj(scope, m_resultObject.value());
+ QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
+#endif //QT_NO_NETWORK
QV4::ScopedValue cb(scope, m_callbackFunction.value());
callback(cb, resultObj);
@@ -188,14 +207,15 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
if (!context || !context->isJSContext)
V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files");
- QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow()));
- if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor())
- url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile);
-
QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());
if (ctx->argc() >= 2 && ctx->args()[1].as<QV4::FunctionObject>())
callbackFunction = ctx->args()[1];
+#ifndef QT_NO_NETWORK
+ QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow()));
+ if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor())
+ url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile);
+
QString localFile = QQmlFile::urlToLocalFileOrQrc(url);
QV4::ScopedValue result(scope);
@@ -243,6 +263,12 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
}
return result->asReturnedValue();
+#else
+ QV4::ScopedValue result(scope);
+ result = resultValue(scope.engine, NetworkError);
+ callback(callbackFunction, result);
+ return result->asReturnedValue();
+#endif
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4include_p.h b/src/qml/jsruntime/qv4include_p.h
index 257dc05e65..1750e6a7e1 100644
--- a/src/qml/jsruntime/qv4include_p.h
+++ b/src/qml/jsruntime/qv4include_p.h
@@ -62,7 +62,9 @@
QT_BEGIN_NAMESPACE
class QQmlEngine;
+#ifndef QT_NO_NETWORK
class QNetworkAccessManager;
+#endif
class QNetworkReply;
class QV4Include : public QObject
{
@@ -90,15 +92,16 @@ private:
static void callback(const QV4::Value &callback, const QV4::Value &status);
QV4::ExecutionEngine *v4;
- QNetworkAccessManager *m_network;
- QPointer<QNetworkReply> m_reply;
-
QUrl m_url;
+
+#ifndef QT_NO_NETWORK
int m_redirectCount;
+ QNetworkAccessManager *m_network;
+ QPointer<QNetworkReply> m_reply;
+#endif
QV4::PersistentValue m_callbackFunction;
QV4::PersistentValue m_resultObject;
-
QV4::PersistentValue m_qmlContext;
};
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index e30c39c8b9..b119aa12af 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -1,5 +1,11 @@
TARGET = QtQml
-QT = core-private network
+QT = core-private
+
+no_network {
+ DEFINES += QT_NO_NETWORK
+} else {
+ QT += network
+}
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 0ad3baf0bb..a5c920d28a 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -53,7 +53,6 @@
#include "qqmlscriptstring.h"
#include "qqmlglobal_p.h"
#include "qqmlcomponent_p.h"
-#include "qqmlnetworkaccessmanagerfactory.h"
#include "qqmldirparser_p.h"
#include "qqmlextensioninterface.h"
#include "qqmllist_p.h"
@@ -63,25 +62,25 @@
#include "qqmlincubator.h"
#include "qqmlabstracturlinterceptor.h"
#include <private/qqmlboundsignal_p.h>
-
#include <QtCore/qstandardpaths.h>
#include <QtCore/qsettings.h>
-
#include <QtCore/qmetaobject.h>
-#include <QNetworkAccessManager>
#include <QDebug>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
#include <QtCore/qmutex.h>
#include <QtCore/qthread.h>
#include <private/qthread_p.h>
+
+#ifndef QT_NO_NETWORK
+#include "qqmlnetworkaccessmanagerfactory.h"
+#include <QNetworkAccessManager>
#include <QtNetwork/qnetworkconfigmanager.h>
+#endif
#include <private/qobject_p.h>
#include <private/qmetaobject_p.h>
-
#include <private/qqmllocale_p.h>
-
#include <private/qqmlbind_p.h>
#include <private/qqmlconnections_p.h>
#include <private/qqmltimer_p.h>
@@ -610,8 +609,10 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
cleanup(0), erroredBindings(0), inProgressCreations(0),
workerScriptEngine(0),
activeObjectCreator(0),
- networkAccessManager(0), networkAccessManagerFactory(0), urlInterceptor(0),
- scarceResourcesRefCount(0), importDatabase(e), typeLoader(e),
+#ifndef QT_NO_NETWORK
+ networkAccessManager(0), networkAccessManagerFactory(0),
+#endif
+ urlInterceptor(0), scarceResourcesRefCount(0), importDatabase(e), typeLoader(e),
uniqueId(1), incubatorCount(0), incubationController(0)
{
}
@@ -1071,7 +1072,17 @@ QQmlAbstractUrlInterceptor *QQmlEngine::urlInterceptor() const
return d->urlInterceptor;
}
+void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
+{
+ if (activeObjectCreator) {
+ activeObjectCreator->finalizeCallbacks()->append(qMakePair(QPointer<QObject>(obj), index));
+ } else {
+ void *args[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args);
+ }
+}
+#ifndef QT_NO_NETWORK
/*!
Sets the \a factory to use for creating QNetworkAccessManager(s).
@@ -1100,16 +1111,6 @@ QQmlNetworkAccessManagerFactory *QQmlEngine::networkAccessManagerFactory() const
return d->networkAccessManagerFactory;
}
-void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
-{
- if (activeObjectCreator) {
- activeObjectCreator->finalizeCallbacks()->append(qMakePair(QPointer<QObject>(obj), index));
- } else {
- void *args[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args);
- }
-}
-
QNetworkAccessManager *QQmlEnginePrivate::createNetworkAccessManager(QObject *parent) const
{
QMutexLocker locker(&networkAccessManagerMutex);
@@ -1148,6 +1149,7 @@ QNetworkAccessManager *QQmlEngine::networkAccessManager() const
Q_D(const QQmlEngine);
return d->getNetworkAccessManager();
}
+#endif // QT_NO_NETWORK
/*!
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index a7eda0ee6c..28bd66047e 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -87,8 +87,10 @@ class QQmlExpression;
class QQmlContext;
class QQmlType;
class QUrl;
+#ifndef QT_NO_NETWORK
class QNetworkAccessManager;
class QQmlNetworkAccessManagerFactory;
+#endif
class QQmlIncubationController;
class Q_QML_EXPORT QQmlEngine : public QJSEngine
{
@@ -115,10 +117,12 @@ public:
bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
+#ifndef QT_NO_NETWORK
void setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *);
QQmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
QNetworkAccessManager *networkAccessManager() const;
+#endif
void setUrlInterceptor(QQmlAbstractUrlInterceptor* urlInterceptor);
QQmlAbstractUrlInterceptor* urlInterceptor() const;
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 88518ac749..7258ffe6ed 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -158,12 +158,12 @@ public:
void registerFinalizeCallback(QObject *obj, int index);
QQmlObjectCreator *activeObjectCreator;
-
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory;
-
+#endif
QHash<QString,QSharedPointer<QQmlImageProviderBase> > imageProviders;
QQmlAbstractUrlInterceptor* urlInterceptor;
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index ea4e9a1013..8ce0cc2026 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -67,6 +67,8 @@ static char assets_string[] = "assets";
#endif
class QQmlFilePrivate;
+
+#ifndef QT_NO_NETWORK
class QQmlFileNetworkReply : public QObject
{
Q_OBJECT
@@ -97,6 +99,7 @@ private:
int m_redirectCount;
QNetworkReply *m_reply;
};
+#endif
class QQmlFilePrivate
{
@@ -114,10 +117,12 @@ public:
Error error;
QString errorString;
-
+#ifndef QT_NO_NETWORK
QQmlFileNetworkReply *reply;
+#endif
};
+#ifndef QT_NO_NETWORK
int QQmlFileNetworkReply::finishedIndex = -1;
int QQmlFileNetworkReply::downloadProgressIndex = -1;
int QQmlFileNetworkReply::networkFinishedIndex = -1;
@@ -200,9 +205,13 @@ void QQmlFileNetworkReply::networkDownloadProgress(qint64 a, qint64 b)
{
emit downloadProgress(a, b);
}
+#endif // QT_NO_NETWORK
QQmlFilePrivate::QQmlFilePrivate()
-: error(None), reply(0)
+: error(None)
+#ifndef QT_NO_NETWORK
+, reply(0)
+#endif
{
}
@@ -225,7 +234,9 @@ QQmlFile::QQmlFile(QQmlEngine *e, const QString &url)
QQmlFile::~QQmlFile()
{
+#ifndef QT_NO_NETWORK
delete d->reply;
+#endif
delete d;
d = 0;
}
@@ -263,8 +274,10 @@ QQmlFile::Status QQmlFile::status() const
{
if (d->url.isEmpty() && d->urlString.isEmpty())
return Null;
+#ifndef QT_NO_NETWORK
else if (d->reply)
return Loading;
+#endif
else if (d->error != QQmlFilePrivate::None)
return Error;
else
@@ -321,7 +334,11 @@ void QQmlFile::load(QQmlEngine *engine, const QUrl &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
+#ifndef QT_NO_NETWORK
d->reply = new QQmlFileNetworkReply(engine, d, url);
+#else
+ d->error = QQmlFilePrivate::NotFound;
+#endif
}
}
@@ -348,10 +365,14 @@ void QQmlFile::load(QQmlEngine *engine, const QString &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
+#ifndef QT_NO_NETWORK
QUrl qurl(url);
d->url = qurl;
d->urlString = QString();
d->reply = new QQmlFileNetworkReply(engine, d, qurl);
+#else
+ d->error = QQmlFilePrivate::NotFound;
+#endif
}
}
@@ -368,6 +389,7 @@ void QQmlFile::clear(QObject *)
clear();
}
+#ifndef QT_NO_NETWORK
bool QQmlFile::connectFinished(QObject *object, const char *method)
{
if (!d || !d->reply) {
@@ -411,6 +433,7 @@ bool QQmlFile::connectDownloadProgress(QObject *object, int method)
return QMetaObject::connect(d->reply, QQmlFileNetworkReply::downloadProgressIndex,
object, method);
}
+#endif
/*!
Returns true if QQmlFile will open \a url synchronously.
diff --git a/src/qml/qml/qqmlfile.h b/src/qml/qml/qqmlfile.h
index b0910cc0f4..3dd683a2cd 100644
--- a/src/qml/qml/qqmlfile.h
+++ b/src/qml/qml/qqmlfile.h
@@ -80,10 +80,12 @@ public:
void clear();
void clear(QObject *);
+#ifndef QT_NO_NETWORK
bool connectFinished(QObject *, const char *);
bool connectFinished(QObject *, int);
bool connectDownloadProgress(QObject *, const char *);
bool connectDownloadProgress(QObject *, int);
+#endif
static bool isSynchronous(const QString &url);
static bool isSynchronous(const QUrl &url);
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
index f9fea0279e..c94db8e168 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
@@ -41,6 +41,8 @@
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_NETWORK
+
/*!
\class QQmlNetworkAccessManagerFactory
\since 5.0
@@ -101,4 +103,6 @@ QQmlNetworkAccessManagerFactory::~QQmlNetworkAccessManagerFactory()
implementation of this method is reentrant.
*/
+#endif //QT_NO_NETWORK
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
index 8e3b94fad3..ba3561b9f4 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
@@ -45,6 +45,7 @@
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_NETWORK
class QNetworkAccessManager;
class Q_QML_EXPORT QQmlNetworkAccessManagerFactory
@@ -55,6 +56,8 @@ public:
};
+#endif //QT_NO_NETWORK
+
QT_END_NAMESPACE
#endif // QQMLNETWORKACCESSMANAGERFACTORY_H
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 52a7562b58..15e8d62efc 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -112,6 +112,7 @@ namespace {
};
}
+#ifndef QT_NO_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
@@ -131,6 +132,7 @@ public slots:
private:
QQmlTypeLoader *l;
};
+#endif // QT_NO_NETWORK
class QQmlTypeLoaderThread : public QQmlThread
{
@@ -138,9 +140,10 @@ class QQmlTypeLoaderThread : public QQmlThread
public:
QQmlTypeLoaderThread(QQmlTypeLoader *loader);
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *networkAccessManager() const;
QQmlTypeLoaderNetworkReplyProxy *networkReplyProxy() const;
-
+#endif // QT_NO_NETWORK
void load(QQmlDataBlob *b);
void loadAsync(QQmlDataBlob *b);
void loadWithStaticData(QQmlDataBlob *b, const QByteArray &);
@@ -163,11 +166,13 @@ private:
void initializeEngineMain(QQmlExtensionInterface *iface, const char *uri);
QQmlTypeLoader *m_loader;
+#ifndef QT_NO_NETWORK
mutable QNetworkAccessManager *m_networkAccessManager;
mutable QQmlTypeLoaderNetworkReplyProxy *m_networkReplyProxy;
+#endif // QT_NO_NETWORK
};
-
+#ifndef QT_NO_NETWORK
QQmlTypeLoaderNetworkReplyProxy::QQmlTypeLoaderNetworkReplyProxy(QQmlTypeLoader *l)
: l(l)
{
@@ -196,7 +201,7 @@ void QQmlTypeLoaderNetworkReplyProxy::manualFinished(QNetworkReply *reply)
l->networkReplyProgress(reply, replySize, replySize);
l->networkReplyFinished(reply);
}
-
+#endif // QT_NO_NETWORK
/*!
\class QQmlDataBlob
@@ -480,6 +485,7 @@ void QQmlDataBlob::done()
{
}
+#ifndef QT_NO_NETWORK
/*!
Invoked if there is a network error while fetching this blob.
@@ -532,6 +538,7 @@ void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError)
setError(error);
}
+#endif // QT_NO_NETWORK
/*!
Called if \a blob, which was previously waited for, has an error.
@@ -730,12 +737,16 @@ void QQmlDataBlob::ThreadData::setProgress(quint8 v)
}
QQmlTypeLoaderThread::QQmlTypeLoaderThread(QQmlTypeLoader *loader)
-: m_loader(loader), m_networkAccessManager(0), m_networkReplyProxy(0)
+: m_loader(loader)
+#ifndef QT_NO_NETWORK
+, m_networkAccessManager(0), m_networkReplyProxy(0)
+#endif // QT_NO_NETWORK
{
// Do that after initializing all the members.
startup();
}
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *QQmlTypeLoaderThread::networkAccessManager() const
{
Q_ASSERT(isThisThread());
@@ -753,6 +764,7 @@ QQmlTypeLoaderNetworkReplyProxy *QQmlTypeLoaderThread::networkReplyProxy() const
Q_ASSERT(m_networkReplyProxy); // Must call networkAccessManager() first
return m_networkReplyProxy;
}
+#endif // QT_NO_NETWORK
void QQmlTypeLoaderThread::load(QQmlDataBlob *b)
{
@@ -810,10 +822,12 @@ void QQmlTypeLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
void QQmlTypeLoaderThread::shutdownThread()
{
+#ifndef QT_NO_NETWORK
delete m_networkAccessManager;
m_networkAccessManager = 0;
delete m_networkReplyProxy;
m_networkReplyProxy = 0;
+#endif // QT_NO_NETWORK
}
void QQmlTypeLoaderThread::loadThread(QQmlDataBlob *b)
@@ -899,12 +913,14 @@ void QQmlTypeLoader::invalidate()
m_thread = 0;
}
+#ifndef QT_NO_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
}
void QQmlTypeLoader::lock()
@@ -1082,7 +1098,7 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
setData(blob, &file);
} else {
-
+#ifndef QT_NO_NETWORK
QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(blob->m_url));
QQmlTypeLoaderNetworkReplyProxy *nrp = m_thread->networkReplyProxy();
blob->addref();
@@ -1099,13 +1115,14 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
#ifdef DATABLOB_DEBUG
qWarning("QQmlDataBlob: requested %s", qPrintable(blob->url().toString()));
-#endif
-
+#endif // DATABLOB_DEBUG
+#endif // QT_NO_NETWORK
}
}
#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
+#ifndef QT_NO_NETWORK
void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
{
Q_ASSERT(m_thread->isThisThread());
@@ -1161,6 +1178,7 @@ void QQmlTypeLoader::networkReplyProgress(QNetworkReply *reply,
m_thread->callDownloadProgressChanged(blob, blob->m_data.progress());
}
}
+#endif // QT_NO_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 01d223bbce..49a4ac716a 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -53,7 +53,9 @@
#include <QtCore/qobject.h>
#include <QtCore/qatomic.h>
+#ifndef QT_NO_NETWORK
#include <QtNetwork/qnetworkreply.h>
+#endif
#include <QtQml/qqmlerror.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlfile.h>
@@ -156,7 +158,9 @@ protected:
virtual void dataReceived(const Data &) = 0;
virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) = 0;
virtual void done();
+#ifndef QT_NO_NETWORK
virtual void networkError(QNetworkReply::NetworkError);
+#endif
virtual void dependencyError(QQmlDataBlob *);
virtual void dependencyComplete(QQmlDataBlob *);
virtual void allDependenciesDone();
@@ -320,17 +324,21 @@ public:
private:
friend class QQmlDataBlob;
friend class QQmlTypeLoaderThread;
+#ifndef QT_NO_NETWORK
friend class QQmlTypeLoaderNetworkReplyProxy;
+#endif // QT_NO_NETWORK
void shutdownThread();
void loadThread(QQmlDataBlob *);
void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
+#ifndef QT_NO_NETWORK
void networkReplyFinished(QNetworkReply *);
void networkReplyProgress(QNetworkReply *, qint64, qint64);
typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies;
+#endif
void setData(QQmlDataBlob *, const QByteArray &);
void setData(QQmlDataBlob *, QQmlFile *);
@@ -362,7 +370,9 @@ private:
QQmlEngine *m_engine;
QQmlTypeLoaderThread *m_thread;
+#ifndef QT_NO_NETWORK
NetworkReplies m_networkReplies;
+#endif
TypeCache m_typeCache;
ScriptCache m_scriptCache;
QmldirCache m_qmldirCache;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index fe02c6633e..af94ec757c 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -70,7 +70,7 @@
using namespace QV4;
-#ifndef QT_NO_XMLSTREAMREADER
+#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
#define V4THROW_REFERENCE(string) { \
ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
@@ -2040,6 +2040,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER
+#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index 7bbfb5243c..df30873915 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>
-#ifndef QT_NO_XMLSTREAMREADER
+#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
QT_BEGIN_NAMESPACE
@@ -64,7 +64,7 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *);
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER
+#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index d322088f61..89f128a0e7 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -159,18 +159,22 @@ QV8Engine::~QV8Engine()
delete m_extensionData[ii];
m_extensionData.clear();
+#if !defined(QT_NO_XMLSTREAMREADER) && defined(QT_NO_NETWORK)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = 0;
+#endif
delete m_listModelData;
m_listModelData = 0;
delete m_v4Engine;
}
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *QV8Engine::networkAccessManager()
{
return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager();
}
+#endif
const QSet<QString> &QV8Engine::illegalNames() const
{
@@ -189,8 +193,10 @@ void QV8Engine::initializeGlobal()
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
+#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
+#endif
qt_add_sqlexceptions(m_v4Engine);
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 4ffd36ca34..9054c731db 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -194,10 +194,12 @@ public:
void freezeObject(const QV4::Value &value);
+#ifndef QT_NO_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).
virtual QNetworkAccessManager *networkAccessManager();
+#endif
// Return the list of illegal id names (the names of the properties on the global object)
const QSet<QString> &illegalNames() const;
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index e819e4ee7d..bc15b2fd9b 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -52,10 +52,12 @@
#include <QtCore/qwaitcondition.h>
#include <QtCore/qfile.h>
#include <QtCore/qdatetime.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
+#ifndef QT_NO_NETWORK
+#include <QtNetwork/qnetworkaccessmanager.h>
#include "qqmlnetworkaccessmanagerfactory.h"
+#endif
#include <private/qv8engine_p.h>
#include <private/qv4serialize_p.h>
@@ -141,7 +143,10 @@ public:
~WorkerEngine();
void init();
+
+#ifndef QT_NO_NETWORK
virtual QNetworkAccessManager *networkAccessManager();
+#endif
QQuickWorkerScriptEnginePrivate *p;
@@ -150,7 +155,9 @@ public:
QV4::PersistentValue onmessage;
private:
QV4::PersistentValue createsend;
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *accessManager;
+#endif
};
WorkerEngine *workerEngine;
@@ -194,14 +201,19 @@ private:
};
QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
-: QV8Engine(0), p(parent), accessManager(0)
+: QV8Engine(0), p(parent)
+#ifndef QT_NO_NETWORK
+, accessManager(0)
+#endif
{
m_v4Engine->v8Engine = this;
}
QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
{
+#ifndef QT_NO_NETWORK
delete accessManager;
+#endif
}
void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
@@ -262,6 +274,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i
return v->asReturnedValue();
}
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
{
if (!accessManager) {
@@ -273,6 +286,7 @@ QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAcc
}
return accessManager;
}
+#endif
QQuickWorkerScriptEnginePrivate::QQuickWorkerScriptEnginePrivate(QQmlEngine *engine)
: workerEngine(0), qmlengine(engine), m_nextId(0)
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 3ae2512c98..42033b6135 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -47,8 +47,10 @@
#include <QtQml/qqmlfile.h>
#include <QtQml/qqmlengine.h>
#include <QtGui/qmovie.h>
+#ifndef QT_NO_NETWORK
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -144,8 +146,10 @@ QQuickAnimatedImage::QQuickAnimatedImage(QQuickItem *parent)
QQuickAnimatedImage::~QQuickAnimatedImage()
{
Q_D(QQuickAnimatedImage);
+#ifndef QT_NO_NETWORK
if (d->reply)
d->reply->deleteLater();
+#endif
delete d->_movie;
qDeleteAll(d->frameMap);
d->frameMap.clear();
@@ -264,10 +268,12 @@ void QQuickAnimatedImage::setSource(const QUrl &url)
if (url == d->url)
return;
+#ifndef QT_NO_NETWORK
if (d->reply) {
d->reply->deleteLater();
d->reply = 0;
}
+#endif
d->setImage(QImage());
qDeleteAll(d->frameMap);
@@ -318,6 +324,7 @@ void QQuickAnimatedImage::load()
d->_movie = new QMovie(lf);
movieRequestFinished();
} else {
+#ifndef QT_NO_NETWORK
if (d->status != Loading) {
d->status = Loading;
emit statusChanged(d->status);
@@ -334,6 +341,7 @@ void QQuickAnimatedImage::load()
this, SLOT(movieRequestFinished()));
QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(requestProgress(qint64,qint64)));
+#endif
}
}
}
@@ -342,8 +350,10 @@ void QQuickAnimatedImage::load()
void QQuickAnimatedImage::movieRequestFinished()
{
+
Q_D(QQuickAnimatedImage);
+#ifndef QT_NO_NETWORK
if (d->reply) {
d->redirectCount++;
if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) {
@@ -359,6 +369,7 @@ void QQuickAnimatedImage::movieRequestFinished()
d->redirectCount=0;
d->_movie = new QMovie(d->reply);
}
+#endif
if (!d->_movie->isValid()) {
qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString();
diff --git a/src/quick/items/qquickanimatedimage_p_p.h b/src/quick/items/qquickanimatedimage_p_p.h
index 9474254252..9b284f966d 100644
--- a/src/quick/items/qquickanimatedimage_p_p.h
+++ b/src/quick/items/qquickanimatedimage_p_p.h
@@ -58,7 +58,9 @@
QT_BEGIN_NAMESPACE
class QMovie;
+#ifndef QT_NO_NETWORK
class QNetworkReply;
+#endif
class QQuickAnimatedImagePrivate : public QQuickImagePrivate
{
@@ -66,7 +68,10 @@ class QQuickAnimatedImagePrivate : public QQuickImagePrivate
public:
QQuickAnimatedImagePrivate()
- : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0), oldPlaying(false)
+ : playing(true), paused(false), preset_currentframe(0), _movie(0), oldPlaying(false)
+#ifndef QT_NO_NETWORK
+ , reply(0), redirectCount(0)
+#endif
{
}
@@ -76,9 +81,11 @@ public:
bool paused;
int preset_currentframe;
QMovie *_movie;
+ bool oldPlaying;
+#ifndef QT_NO_NETWORK
QNetworkReply *reply;
int redirectCount;
- bool oldPlaying;
+#endif
QMap<int, QQuickPixmap *> frameMap;
};
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 66f414d816..5f8dd7b989 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -43,7 +43,9 @@
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
#include <QtQml/qqmlengine.h>
+#ifndef QT_NO_NETWORK
#include <QtNetwork/qnetworkreply.h>
+#endif
#include <QtCore/qfile.h>
#include <QtCore/qmath.h>
#include <QtGui/qguiapplication.h>
@@ -169,9 +171,11 @@ QQuickBorderImage::QQuickBorderImage(QQuickItem *parent)
QQuickBorderImage::~QQuickBorderImage()
{
+#ifndef QT_NO_NETWORK
Q_D(QQuickBorderImage);
if (d->sciReply)
d->sciReply->deleteLater();
+#endif
}
/*!
@@ -270,10 +274,12 @@ void QQuickBorderImage::setSource(const QUrl &url)
if (url == d->url)
return;
+#ifndef QT_NO_NETWORK
if (d->sciReply) {
d->sciReply->deleteLater();
d->sciReply = 0;
}
+#endif
d->url = url;
d->sciurl = QUrl();
@@ -311,6 +317,7 @@ void QQuickBorderImage::load()
setGridScaledImage(QQuickGridScaledImage(&file));
return;
} else {
+#ifndef QT_NO_NETWORK
if (d->progress != 0.0) {
d->progress = 0.0;
emit progressChanged(d->progress);
@@ -320,6 +327,7 @@ void QQuickBorderImage::load()
d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
qmlobject_connect(d->sciReply, QNetworkReply, SIGNAL(finished()),
this, QQuickBorderImage, SLOT(sciRequestFinished()))
+#endif
}
} else {
QQuickPixmap::Options options;
@@ -529,6 +537,7 @@ void QQuickBorderImage::requestFinished()
pixmapChange();
}
+#ifndef QT_NO_NETWORK
#define BORDERIMAGE_MAX_REDIRECT 16
void QQuickBorderImage::sciRequestFinished()
@@ -558,6 +567,7 @@ void QQuickBorderImage::sciRequestFinished()
setGridScaledImage(sci);
}
}
+#endif // QT_NO_NETWORK
void QQuickBorderImage::doUpdate()
{
diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h
index 7f8b172a21..f2764660f6 100644
--- a/src/quick/items/qquickborderimage_p.h
+++ b/src/quick/items/qquickborderimage_p.h
@@ -101,7 +101,9 @@ private:
private Q_SLOTS:
void doUpdate();
void requestFinished() Q_DECL_OVERRIDE;
+#ifndef QT_NO_NETWORK
void sciRequestFinished();
+#endif
private:
Q_DISABLE_COPY(QQuickBorderImage)
diff --git a/src/quick/items/qquickborderimage_p_p.h b/src/quick/items/qquickborderimage_p_p.h
index 478de88a52..1dc530e34e 100644
--- a/src/quick/items/qquickborderimage_p_p.h
+++ b/src/quick/items/qquickborderimage_p_p.h
@@ -58,17 +58,20 @@
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_NETWORK
class QNetworkReply;
+#endif
class QQuickBorderImagePrivate : public QQuickImageBasePrivate
{
Q_DECLARE_PUBLIC(QQuickBorderImage)
public:
QQuickBorderImagePrivate()
- : border(0), sciReply(0),
- horizontalTileMode(QQuickBorderImage::Stretch),
- verticalTileMode(QQuickBorderImage::Stretch),
- redirectCount(0), pixmapChanged(false)
+ : border(0), horizontalTileMode(QQuickBorderImage::Stretch),
+ verticalTileMode(QQuickBorderImage::Stretch), pixmapChanged(false)
+#ifndef QT_NO_NETWORK
+ , sciReply(0), redirectCount(0)
+#endif
{
}
@@ -90,12 +93,14 @@ public:
QQuickScaleGrid *border;
QUrl sciurl;
- QNetworkReply *sciReply;
QQuickBorderImage::TileMode horizontalTileMode;
QQuickBorderImage::TileMode verticalTileMode;
- int redirectCount;
-
bool pixmapChanged : 1;
+
+#ifndef QT_NO_NETWORK
+ QNetworkReply *sciReply;
+ int redirectCount;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index 1c14ff8d57..90ba867ea8 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -1,7 +1,12 @@
TARGET = QtQuick
QT = core-private gui-private qml-private
-QT_PRIVATE = network
+!no_network {
+ QT_PRIVATE = network
+}
+no_network {
+ DEFINES += QT_NO_NETWORK
+}
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp
index 64fd458ef0..b7367f3934 100644
--- a/src/quick/util/qquickfontloader.cpp
+++ b/src/quick/util/qquickfontloader.cpp
@@ -45,14 +45,18 @@
#include <QStringList>
#include <QUrl>
#include <QDebug>
-#include <QNetworkRequest>
-#include <QNetworkReply>
+
#include <QFontDatabase>
#include <private/qobject_p.h>
#include <qqmlinfo.h>
#include <qqmlfile.h>
+#ifndef QT_NO_NETWORK
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#endif
+
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
@@ -66,28 +70,37 @@ Q_OBJECT
public:
explicit QQuickFontObject(int _id = -1);
+#ifndef QT_NO_NETWORK
void download(const QUrl &url, QNetworkAccessManager *manager);
Q_SIGNALS:
void fontDownloaded(const QString&, QQuickFontLoader::Status);
+private:
+ int redirectCount;
+ QNetworkReply *reply;
+
private Q_SLOTS:
void replyFinished();
+#endif // QT_NO_NETWORK
public:
int id;
-private:
- QNetworkReply *reply;
- int redirectCount;
-
Q_DISABLE_COPY(QQuickFontObject)
};
QQuickFontObject::QQuickFontObject(int _id)
- : QObject(0), id(_id), reply(0), redirectCount(0) {}
+ : QObject(0)
+#ifndef QT_NO_NETWORK
+ ,redirectCount(0), reply(0)
+#endif
+ ,id(_id)
+{
+}
+#ifndef QT_NO_NETWORK
void QQuickFontObject::download(const QUrl &url, QNetworkAccessManager *manager)
{
QNetworkRequest req(url);
@@ -128,7 +141,7 @@ void QQuickFontObject::replyFinished()
reply = 0;
}
}
-
+#endif // QT_NO_NETWORK
class QQuickFontLoaderPrivate : public QObjectPrivate
{
@@ -255,6 +268,7 @@ void QQuickFontLoader::setSource(const QUrl &url)
}
} else {
if (!fontLoaderFonts()->map.contains(d->url)) {
+#ifndef QT_NO_NETWORK
QQuickFontObject *fo = new QQuickFontObject;
fontLoaderFonts()->map[d->url] = fo;
fo->download(d->url, qmlEngine(this)->networkAccessManager());
@@ -262,13 +276,20 @@ void QQuickFontLoader::setSource(const QUrl &url)
emit statusChanged();
QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)),
this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status)));
+#else
+// Silently fail if compiled with no_network
+#endif
} else {
QQuickFontObject *fo = fontLoaderFonts()->map[d->url];
if (fo->id == -1) {
+#ifndef QT_NO_NETWORK
d->status = Loading;
emit statusChanged();
QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)),
this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status)));
+#else
+// Silently fail if compiled with no_network
+#endif
}
else
updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready);
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 7d9997b9c8..23b2887fac 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qquickpixmapcache_p.h"
-#include <qqmlnetworkaccessmanagerfactory.h>
#include <qquickimageprovider.h>
#include <qqmlengine.h>
@@ -55,7 +54,6 @@
#include <QCoreApplication>
#include <QImageReader>
#include <QHash>
-#include <QNetworkReply>
#include <QPixmapCache>
#include <QFile>
#include <QThread>
@@ -66,10 +64,15 @@
#include <QWaitCondition>
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
-#include <QSslError>
#include <QQmlFile>
#include <QMetaMethod>
+#ifndef QT_NO_NETWORK
+#include <qqmlnetworkaccessmanagerfactory.h>
+#include <QNetworkReply>
+#include <QSslError>
+#endif
+
#include <private/qquickprofiler_p.h>
#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT 8
@@ -203,7 +206,9 @@ private:
friend class QQuickPixmapReaderThreadObject;
void processJobs();
void processJob(QQuickPixmapReply *, const QUrl &, const QString &, AutoTransform, QQuickImageProvider::ImageType, QQuickImageProvider *);
+#ifndef QT_NO_NETWORK
void networkRequestDone(QNetworkReply *);
+#endif
void asyncResponseFinished(QQuickImageResponse *);
QList<QQuickPixmapReply*> jobs;
@@ -215,10 +220,11 @@ private:
QQuickPixmapReaderThreadObject *threadObject;
QWaitCondition waitCondition;
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *networkAccessManager();
QNetworkAccessManager *accessManager;
-
QHash<QNetworkReply*,QQuickPixmapReply*> networkJobs;
+#endif
QHash<QQuickImageResponse*,QQuickPixmapReply*> asyncResponses;
static int replyDownloadProgress;
@@ -343,6 +349,7 @@ QQuickPixmapReply::Event::~Event()
delete textureFactory;
}
+#ifndef QT_NO_NETWORK
QNetworkAccessManager *QQuickPixmapReader::networkAccessManager()
{
if (!accessManager) {
@@ -351,6 +358,7 @@ QNetworkAccessManager *QQuickPixmapReader::networkAccessManager()
}
return accessManager;
}
+#endif
static void maybeRemoveAlpha(QImage *image)
{
@@ -421,7 +429,10 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e
}
QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng)
-: QThread(eng), engine(eng), threadObject(0), accessManager(0)
+: QThread(eng), engine(eng), threadObject(0)
+#ifndef QT_NO_NETWORK
+, accessManager(0)
+#endif
{
eventLoopQuitHack = new QObject;
eventLoopQuitHack->moveToThread(this);
@@ -443,6 +454,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
delete reply;
}
jobs.clear();
+#ifndef QT_NO_NETWORK
QList<QQuickPixmapReply*> activeJobs = networkJobs.values() + asyncResponses.values();
foreach (QQuickPixmapReply *reply, activeJobs ) {
if (reply->loading) {
@@ -450,6 +462,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
reply->data = 0;
}
}
+#endif
if (threadObject) threadObject->processJobs();
mutex.unlock();
@@ -457,6 +470,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
wait();
}
+#ifndef QT_NO_NETWORK
void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
{
QQuickPixmapReply *job = networkJobs.take(reply);
@@ -506,6 +520,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
// kick off event loop again incase we have dropped below max request count
threadObject->processJobs();
}
+#endif // QT_NO_NETWORK
void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response)
{
@@ -557,8 +572,10 @@ bool QQuickPixmapReaderThreadObject::event(QEvent *e)
void QQuickPixmapReaderThreadObject::networkRequestDone()
{
+#ifndef QT_NO_NETWORK
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reader->networkRequestDone(reply);
+#endif
}
void QQuickPixmapReaderThreadObject::asyncResponseFinished()
@@ -577,6 +594,7 @@ void QQuickPixmapReader::processJobs()
// Clean cancelled jobs
if (!cancelled.isEmpty()) {
+#ifndef QT_NO_NETWORK
for (int i = 0; i < cancelled.count(); ++i) {
QQuickPixmapReply *job = cancelled.at(i);
QNetworkReply *reply = networkJobs.key(job, 0);
@@ -599,6 +617,7 @@ void QQuickPixmapReader::processJobs()
job->deleteLater();
}
cancelled.clear();
+#endif
}
if (!jobs.isEmpty()) {
@@ -619,7 +638,11 @@ void QQuickPixmapReader::processJobs()
usableJob = true;
} else {
localFile = QQmlFile::urlToLocalFileOrQrc(url);
- usableJob = !localFile.isEmpty() || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT;
+ usableJob = !localFile.isEmpty()
+#ifndef QT_NO_NETWORK
+ || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT
+#endif
+ ;
}
@@ -744,6 +767,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
runningJob->postReply(errorCode, errorStr, readSize, QQuickTextureFactory::textureFactoryForImage(image));
mutex.unlock();
} else {
+#ifndef QT_NO_NETWORK
// Network resource
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
@@ -753,6 +777,9 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
networkJobs.insert(reply, runningJob);
+#else
+// Silently fail if compiled with no_network
+#endif
}
}
}
@@ -809,11 +836,13 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply)
void QQuickPixmapReader::run()
{
if (replyDownloadProgress == -1) {
+#ifndef QT_NO_NETWORK
replyDownloadProgress = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex();
replyFinished = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex();
- downloadProgress = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex();
const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject;
threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
+#endif
+ downloadProgress = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex();
}
mutex.lock();