summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-21 07:04:28 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-24 02:37:36 (GMT)
commit80f946828264c8e9e9213e0b8760f772090c979f (patch)
tree73a9199e435df2b8e07488c9c75b15f7bba29583 /src/declarative
parentd006d2c64c5f9ee53189c86c88512558dd9bca41 (diff)
downloadQt-80f946828264c8e9e9213e0b8760f772090c979f.zip
Qt-80f946828264c8e9e9213e0b8760f772090c979f.tar.gz
Qt-80f946828264c8e9e9213e0b8760f772090c979f.tar.bz2
Allow resource files to be loaded in WorkerScript
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 8182998..dc5bc6e 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -189,7 +189,7 @@ QScriptValue QDeclarativeWorkerScriptEnginePrivate::onMessage(QScriptContext *ct
if (!script)
return engine->undefinedValue();
- if (ctxt->argumentCount() >= 1)
+ if (ctxt->argumentCount() >= 1)
script->callback = ctxt->argument(0);
return script->callback;
@@ -275,12 +275,20 @@ void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVarian
}
}
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
{
- if (url.isRelative() || url.scheme() != QLatin1String("file"))
+ if (url.isRelative())
return;
- QString fileName = url.toLocalFile();
+ QString fileName = toLocalFileOrQrc(url);
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {