diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-02 11:22:26 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-02 20:53:14 +0100 |
commit | 57665bf23a00eca240d26c6267ca2bed1a052c0b (patch) | |
tree | f0630717b8c7cf46b2127a9b1590fef611666706 /src/qml/qml/qqmlexpression.cpp | |
parent | 1e6f2fc90ddf0026f2ae757ad4233974b99b85ab (diff) |
Make QQmlExpression more robust when initializing from script string
Don't require a binding id to initialize the url/col/line. Fixes
tst_qqmlexpression with the new compiler code path, where the id isn't needed.
Change-Id: Ic09d850038c93fdc4f2bee6190cb515081dd5865
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlexpression.cpp')
-rw-r--r-- | src/qml/qml/qqmlexpression.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index cdb5813221..b64dd9bd39 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -160,8 +160,7 @@ QQmlExpression::QQmlExpression(const QQmlScriptString &script, QQmlContext *ctxt QQmlContextData *evalCtxtData = QQmlContextData::get(ctxt ? ctxt : scriptPrivate->context); QObject *scopeObject = scope ? scope : scriptPrivate->scope; - int id = scriptPrivate->bindingId; - if (id >= 0) { + if (scriptPrivate->context) { QQmlContextData *ctxtdata = QQmlContextData::get(scriptPrivate->context); QQmlEnginePrivate *engine = QQmlEnginePrivate::get(scriptPrivate->context->engine()); if (engine && ctxtdata && !ctxtdata->url.isEmpty()) { @@ -169,9 +168,16 @@ QQmlExpression::QQmlExpression(const QQmlScriptString &script, QQmlContext *ctxt Q_ASSERT(typeData); if (QQmlCompiledData *cdata = typeData->compiledData()) { - defaultConstruction = false; - d->init(evalCtxtData, cdata->primitives.at(id), scopeObject, - cdata->name, scriptPrivate->lineNumber, scriptPrivate->columnNumber); + int id = scriptPrivate->bindingId; + if (id >= 0) { + defaultConstruction = false; + d->init(evalCtxtData, cdata->primitives.at(id), scopeObject, + cdata->name, scriptPrivate->lineNumber, scriptPrivate->columnNumber); + } else { + d->url = cdata->name; + d->line = scriptPrivate->lineNumber; + d->column = scriptPrivate->columnNumber; + } } typeData->release(); |