diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-05 03:40:16 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-05 03:40:16 (GMT) |
commit | 186a38c683cbec6a2a141245d5e428d85c073b8f (patch) | |
tree | 1bd2f2d52a832c342a4ed6dcf1a878cef95b8958 | |
parent | 56d5cac2f2bbee9e4e1ee6ac6ac9670926bb329f (diff) | |
download | Qt-186a38c683cbec6a2a141245d5e428d85c073b8f.zip Qt-186a38c683cbec6a2a141245d5e428d85c073b8f.tar.gz Qt-186a38c683cbec6a2a141245d5e428d85c073b8f.tar.bz2 |
Mark function contexts as temporary
QTBUG-5690
-rw-r--r-- | src/declarative/qml/qmlbindingoptimizations.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 7 | ||||
-rw-r--r-- | src/declarative/qml/qmlvmemetaobject.cpp | 1 |
6 files changed, 18 insertions, 5 deletions
diff --git a/src/declarative/qml/qmlbindingoptimizations.cpp b/src/declarative/qml/qmlbindingoptimizations.cpp index d7105b2..868440e 100644 --- a/src/declarative/qml/qmlbindingoptimizations.cpp +++ b/src/declarative/qml/qmlbindingoptimizations.cpp @@ -145,8 +145,10 @@ void QmlOptimizedBindings::run(Binding *binding) qWarning("ERROR: Circular binding"); QmlContext *context = QmlAbstractExpression::context(); - if (!context) + if (!context) { + qWarning("QmlOptimizedBindings: Attempted to evaluate an expression in an invalid context"); return; + } QmlContextPrivate *cp = QmlContextPrivate::get(context); if (binding->property & 0xFFFF0000) { diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 4467cce..e063981 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -57,8 +57,8 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() -: parent(0), engine(0), isInternal(false), propertyNames(0), notifyIndex(-1), - highPriorityCount(0), imports(0), expressions(0), contextObjects(0), +: parent(0), engine(0), isInternal(false), isTemporary(false), propertyNames(0), + notifyIndex(-1), highPriorityCount(0), imports(0), expressions(0), contextObjects(0), idValues(0), idValueCount(0), optimizedBindings(0) { } diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index bc8c357..cb89474 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -86,7 +86,9 @@ public: QmlContext *parent; QmlEngine *engine; + bool isInternal; + bool isTemporary; QmlIntegerCache *propertyNames; QList<QVariant> propertyValues; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 0e9b7c4..d5e3884 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -648,7 +648,10 @@ QmlContext *QmlEnginePrivate::getContext(QScriptContext *ctxt) QScriptValue scopeNode = QScriptDeclarativeClass::scopeChainValue(ctxt, -3); Q_ASSERT(scopeNode.isValid()); Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass); - return contextClass->contextFromValue(scopeNode); + QmlContext *context = contextClass->contextFromValue(scopeNode); + while (context && QmlContextPrivate::get(context)->isTemporary) + context = context->parentContext(); + return context; } QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt, diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index ab9f9ea..652c5f8 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -421,7 +421,12 @@ QVariant QmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) Q_Q(QmlExpression); QVariant rv; - if (!q->engine() || (!data->sse.isValid() && data->expression.isEmpty())) + if (!q->engine()) { + qWarning("QmlExpression: Attempted to evaluate an expression in an invalid context"); + return rv; + } + + if (!data->sse.isValid() && data->expression.isEmpty()) return rv; #ifdef Q_ENABLE_PERFORMANCE_LOG diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 8588eff..3b1f068 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -273,6 +273,7 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) rv = expr.value(); } else { QmlContext newCtxt(ctxt); + QmlContextPrivate::get(&newCtxt)->isTemporary = true; QMetaMethod m = method(_id); QList<QByteArray> names = m.parameterNames(); for (int ii = 0; ii < names.count(); ++ii) |