summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-14 07:59:52 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-14 07:59:52 (GMT)
commitb70dd15c635990306bab35e440d7b561cac7c67e (patch)
treeb77966b6e81063257cff343bc61ba9c0dc4cb9b3 /src/declarative/qml
parentb915d0aa46599f707df4db6eb33965602a2d7422 (diff)
parentd9ab23c190de774ea093652060981e14ac5aeaf8 (diff)
downloadQt-b70dd15c635990306bab35e440d7b561cac7c67e.zip
Qt-b70dd15c635990306bab35e440d7b561cac7c67e.tar.gz
Qt-b70dd15c635990306bab35e440d7b561cac7c67e.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Qt.include() support in worker scripts Only add "include" property in non-workerscript threads Missing files from 645b9ee9dd6e0576542cc61872ecedb408ca8a89 Reduce the chance of AnchorAnimation animating geometry changes it Add Qt.include() method for scoped inclusion of JavaScript files Fix crash in ParentAnimation. Revert "Fix crash in ParentAnimation." Symbian build fix to declarative auto and benchmark tests Revert "Use raster graphicssystem for qml.app on OS X." Fix crash in ParentAnimation. Minor declarative webview tweaks Removed dependency of QDeclarativeWebView to private Qt (Declarative) API Note that you need to unset a flag to create a visual item Follow-up on Flickable changes. ListModel::get() should return undefined if bad index specified Add an example spinner. Fix crash on remote content. Dates and variants are not considered nested objects
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp46
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp316
-rw-r--r--src/declarative/qml/qdeclarativeinclude_p.h115
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp6
-rw-r--r--src/declarative/qml/qml.pri2
10 files changed, 498 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index b43b4d0..e4405f7 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -514,7 +514,9 @@ void QDeclarativeCompositeTypeManager::checkComplete(QDeclarativeCompositeTypeDa
unit->errors = u->errors;
doComplete(unit);
return;
- } else if (u->status == QDeclarativeCompositeTypeData::Waiting) {
+ } else if (u->status == QDeclarativeCompositeTypeData::Waiting
+ || u->status == QDeclarativeCompositeTypeData::WaitingResources)
+ {
waiting++;
}
}
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index b61b8cb..6a13f15 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -659,7 +659,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object
if (iter == enginePriv->m_sharedScriptImports.end()) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(enginePriv->contextClass->newContext(0, 0));
+ scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url));
scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
@@ -685,7 +685,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(enginePriv->contextClass->newContext(this, 0));
+ scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url));
scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 1336a1a..1ebedbb 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -51,11 +51,13 @@ QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
ContextData() : overrideObject(0), isSharedContext(true) {}
- ContextData(QDeclarativeContextData *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
+ ContextData(QDeclarativeContextData *c, QObject *o)
+ : context(c), scopeObject(o), overrideObject(0), isSharedContext(false), isUrlContext(false) {}
QDeclarativeGuardedContextData context;
QDeclarativeGuard<QObject> scopeObject;
QObject *overrideObject;
- bool isSharedContext;
+ bool isSharedContext:1;
+ bool isUrlContext:1;
QDeclarativeContextData *getContext(QDeclarativeEngine *engine) {
if (isSharedContext) {
@@ -74,6 +76,18 @@ struct ContextData : public QScriptDeclarativeClass::Object {
}
};
+struct UrlContextData : public ContextData {
+ UrlContextData(QDeclarativeContextData *c, QObject *o, const QString &u)
+ : ContextData(c, o), url(u) {
+ isUrlContext = true;
+ }
+ UrlContextData(const QString &u)
+ : ContextData(0, 0), url(u) {
+ isUrlContext = true;
+ }
+ QString url;
+};
+
/*
The QDeclarativeContextScriptClass handles property access for a QDeclarativeContext
via QtScript.
@@ -95,6 +109,21 @@ QScriptValue QDeclarativeContextScriptClass::newContext(QDeclarativeContextData
return newObject(scriptEngine, this, new ContextData(context, scopeObject));
}
+QScriptValue QDeclarativeContextScriptClass::newUrlContext(QDeclarativeContextData *context, QObject *scopeObject,
+ const QString &url)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return newObject(scriptEngine, this, new UrlContextData(context, scopeObject, url));
+}
+
+QScriptValue QDeclarativeContextScriptClass::newUrlContext(const QString &url)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return newObject(scriptEngine, this, new UrlContextData(url));
+}
+
QScriptValue QDeclarativeContextScriptClass::newSharedContext()
{
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
@@ -111,6 +140,19 @@ QDeclarativeContextData *QDeclarativeContextScriptClass::contextFromValue(const
return data->getContext(engine);
}
+QUrl QDeclarativeContextScriptClass::urlFromValue(const QScriptValue &v)
+{
+ if (scriptClass(v) != this)
+ return QUrl();
+
+ ContextData *data = (ContextData *)object(v);
+ if (data->isUrlContext) {
+ return QUrl(static_cast<UrlContextData *>(data)->url);
+ } else {
+ return QUrl();
+ }
+}
+
QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
{
if (scriptClass(v) != this)
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
index 1936d38..1215b00 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -68,9 +68,13 @@ public:
~QDeclarativeContextScriptClass();
QScriptValue newContext(QDeclarativeContextData *, QObject * = 0);
+ QScriptValue newUrlContext(QDeclarativeContextData *, QObject *, const QString &);
+ QScriptValue newUrlContext(const QString &);
QScriptValue newSharedContext();
QDeclarativeContextData *contextFromValue(const QScriptValue &);
+ QUrl urlFromValue(const QScriptValue &);
+
QObject *setOverrideObject(QScriptValue &, QObject *);
protected:
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 94e6771..2c89abd 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -67,6 +67,7 @@
#include "qdeclarativeextensioninterface.h"
#include "private/qdeclarativelist_p.h"
#include "private/qdeclarativetypenamecache_p.h"
+#include "private/qdeclarativeinclude_p.h"
#include <QtCore/qmetaobject.h>
#include <QScriptClass>
@@ -204,6 +205,11 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
// XXX used to add Qt.Sound class.
//types
+ if (mainthread)
+ qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::include, 2));
+ else
+ qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::worker_include, 2));
+
qtObject.setProperty(QLatin1String("isQtObject"), newFunction(QDeclarativeEnginePrivate::isQtObject, 1));
qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4));
qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4));
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index 1b34aee..7690edd 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -76,6 +76,7 @@ public:
void explicitSetProperty(const QString &, const QScriptValue &);
const QScriptValue &globalObject() const { return m_globalObject; }
+
const QSet<QString> &illegalNames() const { return m_illegalNames; }
private:
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
new file mode 100644
index 0000000..97220f1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeinclude_p.h"
+
+#include <QtScript/qscriptengine>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qfile.h>
+
+#include <private/qdeclarativeengine_p.h>
+#include <private/qdeclarativeglobalscriptclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeInclude::QDeclarativeInclude(const QUrl &url,
+ QDeclarativeEngine *engine,
+ QScriptContext *ctxt)
+: QObject(engine), m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0)
+{
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ m_context = ep->contextClass->contextFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3));
+
+ m_scope[0] = QScriptDeclarativeClass::scopeChainValue(ctxt, -4);
+ m_scope[1] = QScriptDeclarativeClass::scopeChainValue(ctxt, -5);
+
+ m_scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ m_network = QDeclarativeScriptEngine::get(m_scriptEngine)->networkAccessManager();
+
+ m_result = resultValue(m_scriptEngine);
+
+ QNetworkRequest request;
+ request.setUrl(url);
+
+ m_reply = m_network->get(request);
+ QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
+}
+
+QDeclarativeInclude::~QDeclarativeInclude()
+{
+ delete m_reply;
+}
+
+QScriptValue QDeclarativeInclude::resultValue(QScriptEngine *engine, Status status)
+{
+ QScriptValue result = engine->newObject();
+ result.setProperty(QLatin1String("OK"), QScriptValue(engine, Ok));
+ result.setProperty(QLatin1String("LOADING"), QScriptValue(engine, Loading));
+ result.setProperty(QLatin1String("NETWORK_ERROR"), QScriptValue(engine, NetworkError));
+ result.setProperty(QLatin1String("EXCEPTION"), QScriptValue(engine, Exception));
+
+ result.setProperty(QLatin1String("status"), QScriptValue(engine, status));
+ return result;
+}
+
+QScriptValue QDeclarativeInclude::result() const
+{
+ return m_result;
+}
+
+void QDeclarativeInclude::setCallback(const QScriptValue &c)
+{
+ m_callback = c;
+}
+
+QScriptValue QDeclarativeInclude::callback() const
+{
+ return m_callback;
+}
+
+#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15
+void QDeclarativeInclude::finished()
+{
+ m_redirectCount++;
+
+ if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ m_url = m_url.resolved(redirect.toUrl());
+ delete m_reply;
+
+ QNetworkRequest request;
+ request.setUrl(m_url);
+
+ m_reply = m_network->get(request);
+ QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
+ return;
+ }
+ }
+
+ if (m_reply->error() == QNetworkReply::NoError) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_engine);
+
+ QByteArray data = m_reply->readAll();
+
+ QString code = QString::fromUtf8(data);
+
+ QString urlString = m_url.toString();
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(m_scriptEngine);
+ scriptContext->pushScope(ep->contextClass->newUrlContext(m_context, 0, urlString));
+ scriptContext->pushScope(m_scope[0]);
+
+ scriptContext->pushScope(m_scope[1]);
+ scriptContext->setActivationObject(m_scope[1]);
+
+ m_scriptEngine->evaluate(code, urlString, 1);
+
+ m_scriptEngine->popContext();
+
+ if (m_scriptEngine->hasUncaughtException()) {
+ m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Exception));
+ m_result.setProperty(QLatin1String("exception"), m_scriptEngine->uncaughtException());
+ m_scriptEngine->clearExceptions();
+ } else {
+ m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Ok));
+ }
+ } else {
+ m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, NetworkError));
+ }
+
+ callback(m_scriptEngine, m_callback, m_result);
+
+ disconnect();
+ deleteLater();
+}
+
+void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback, QScriptValue &status)
+{
+ if (callback.isValid()) {
+ QScriptValue args = engine->newArray(1);
+ args.setProperty(0, status);
+ callback.call(QScriptValue(), args);
+ }
+}
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ if (url.scheme() == QLatin1String("qrc")) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ return QString();
+ }
+ return url.toLocalFile();
+}
+
+QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if (ctxt->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ QUrl contextUrl = ep->contextClass->urlFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3));
+ if (contextUrl.isEmpty())
+ return ctxt->throwError(QLatin1String("Qt.include(): Can only be called from JavaScript files"));
+
+ QString urlString = ctxt->argument(0).toString();
+ QUrl url(ctxt->argument(0).toString());
+ if (url.isRelative()) {
+ url = QUrl(contextUrl).resolved(url);
+ urlString = url.toString();
+ }
+
+ QString localFile = toLocalFileOrQrc(url);
+
+ QScriptValue func = ctxt->argument(1);
+ if (!func.isFunction())
+ func = QScriptValue();
+
+ QScriptValue result;
+ if (localFile.isEmpty()) {
+ QDeclarativeInclude *i =
+ new QDeclarativeInclude(url, QDeclarativeEnginePrivate::getEngine(engine), ctxt);
+
+ if (func.isValid())
+ i->setCallback(func);
+
+ result = i->result();
+ } else {
+
+ QFile f(localFile);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString code = QString::fromUtf8(data);
+
+ QDeclarativeContextData *context =
+ ep->contextClass->contextFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3));
+
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine);
+ scriptContext->pushScope(ep->contextClass->newUrlContext(context, 0, urlString));
+ scriptContext->pushScope(ep->globalClass->globalObject());
+ QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5);
+ scriptContext->pushScope(scope);
+ scriptContext->setActivationObject(scope);
+
+ engine->evaluate(code, urlString, 1);
+
+ engine->popContext();
+
+ if (engine->hasUncaughtException()) {
+ result = resultValue(engine, Exception);
+ result.setProperty(QLatin1String("exception"), engine->uncaughtException());
+ engine->clearExceptions();
+ } else {
+ result = resultValue(engine, Ok);
+ }
+ callback(engine, func, result);
+ } else {
+ result = resultValue(engine, NetworkError);
+ callback(engine, func, result);
+ }
+ }
+
+ return result;
+}
+
+QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if (ctxt->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ QString urlString = ctxt->argument(0).toString();
+ QUrl url(ctxt->argument(0).toString());
+ if (url.isRelative()) {
+ QString contextUrl = QScriptDeclarativeClass::scopeChainValue(ctxt, -3).data().toString();
+ Q_ASSERT(!contextUrl.isEmpty());
+
+ url = QUrl(contextUrl).resolved(url);
+ urlString = url.toString();
+ }
+
+ QString localFile = toLocalFileOrQrc(url);
+
+ QScriptValue func = ctxt->argument(1);
+ if (!func.isFunction())
+ func = QScriptValue();
+
+ QScriptValue result;
+ if (!localFile.isEmpty()) {
+
+ QFile f(localFile);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString code = QString::fromUtf8(data);
+
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine);
+ QScriptValue urlContext = engine->newObject();
+ urlContext.setData(QScriptValue(engine, urlString));
+ scriptContext->pushScope(urlContext);
+
+ QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -4);
+ scriptContext->pushScope(scope);
+ scriptContext->setActivationObject(scope);
+
+ engine->evaluate(code, urlString, 1);
+
+ engine->popContext();
+
+ if (engine->hasUncaughtException()) {
+ result = resultValue(engine, Exception);
+ result.setProperty(QLatin1String("exception"), engine->uncaughtException());
+ engine->clearExceptions();
+ } else {
+ result = resultValue(engine, Ok);
+ }
+ callback(engine, func, result);
+ } else {
+ result = resultValue(engine, NetworkError);
+ callback(engine, func, result);
+ }
+ }
+
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinclude_p.h b/src/declarative/qml/qdeclarativeinclude_p.h
new file mode 100644
index 0000000..3124374
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinclude_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEINCLUDE_P_H
+#define QDECLARATIVEINCLUDE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtScript/qscriptvalue.h>
+
+#include <private/qdeclarativecontext_p.h>
+#include <private/qdeclarativeguard_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QScriptContext;
+class QScriptEngine;
+class QNetworkAccessManager;
+class QNetworkReply;
+class QDeclarativeInclude : public QObject
+{
+ Q_OBJECT
+public:
+ enum Status {
+ Ok = 0,
+ Loading = 1,
+ NetworkError = 2,
+ Exception = 3
+ };
+
+ QDeclarativeInclude(const QUrl &, QDeclarativeEngine *, QScriptContext *ctxt);
+ ~QDeclarativeInclude();
+
+ void setCallback(const QScriptValue &);
+ QScriptValue callback() const;
+
+ QScriptValue result() const;
+
+ static QScriptValue resultValue(QScriptEngine *, Status status = Loading);
+ static void callback(QScriptEngine *, QScriptValue &callback, QScriptValue &status);
+
+ static QScriptValue include(QScriptContext *ctxt, QScriptEngine *engine);
+ static QScriptValue worker_include(QScriptContext *ctxt, QScriptEngine *engine);
+
+public slots:
+ void finished();
+
+private:
+ QDeclarativeEngine *m_engine;
+ QScriptEngine *m_scriptEngine;
+ QNetworkAccessManager *m_network;
+ QDeclarativeGuard<QNetworkReply> m_reply;
+
+ QUrl m_url;
+ int m_redirectCount;
+ QScriptValue m_callback;
+ QScriptValue m_result;
+ QDeclarativeGuardedContextData m_context;
+ QScriptValue m_scope[2];
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEINCLUDE_P_H
+
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index c55998f..4b687a9 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -289,7 +289,11 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QScriptValue activation = getWorker(id);
- QScriptContext *ctxt = workerEngine->pushContext();
+ QScriptContext *ctxt = QScriptDeclarativeClass::pushCleanContext(workerEngine);
+ QScriptValue urlContext = workerEngine->newObject();
+ urlContext.setData(QScriptValue(workerEngine, fileName));
+ ctxt->pushScope(urlContext);
+ ctxt->pushScope(activation);
ctxt->setActivationObject(activation);
workerEngine->baseUrl = url;
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index dab9767..12f9794 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -9,6 +9,7 @@ SOURCES += \
$$PWD/qdeclarativeproperty.cpp \
$$PWD/qdeclarativecomponent.cpp \
$$PWD/qdeclarativecontext.cpp \
+ $$PWD/qdeclarativeinclude.cpp \
$$PWD/qdeclarativecustomparser.cpp \
$$PWD/qdeclarativepropertyvaluesource.cpp \
$$PWD/qdeclarativepropertyvalueinterceptor.cpp \
@@ -92,6 +93,7 @@ HEADERS += \
$$PWD/qdeclarativeinfo.h \
$$PWD/qdeclarativeproperty_p.h \
$$PWD/qdeclarativecontext_p.h \
+ $$PWD/qdeclarativeinclude_p.h \
$$PWD/qdeclarativecompositetypedata_p.h \
$$PWD/qdeclarativecompositetypemanager_p.h \
$$PWD/qdeclarativelist.h \