From 80f946828264c8e9e9213e0b8760f772090c979f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 21 May 2010 17:04:28 +1000 Subject: Allow resource files to be loaded in WorkerScript --- src/declarative/qml/qdeclarativeworkerscript.cpp | 14 +++++++++++--- 1 file 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)) { -- cgit v0.12