aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljsscopebuilder.cpp
diff options
context:
space:
mode:
authorChristian Kamm <[email protected]>2010-11-12 14:53:00 +0100
committerChristian Kamm <[email protected]>2010-11-15 10:36:22 +0100
commitf7a077b1fa04385dee1e796b89e1de08e4e90aad (patch)
tree735bef913644ed7c33fce07da9cae175c5ed5e27 /src/libs/qmljs/qmljsscopebuilder.cpp
parent443be8eea6db111c02c3fa00a0c3446f748d6346 (diff)
QmlJS: Avoid infinite loop with recursive prototypes.
Diffstat (limited to 'src/libs/qmljs/qmljsscopebuilder.cpp')
-rw-r--r--src/libs/qmljs/qmljsscopebuilder.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp
index 7cd3261232d..1809b954bd0 100644
--- a/src/libs/qmljs/qmljsscopebuilder.cpp
+++ b/src/libs/qmljs/qmljsscopebuilder.cpp
@@ -202,8 +202,10 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
// check if the object has a Qt.ListElement or Qt.Connections ancestor
// ### allow only signal bindings for Connections
- const ObjectValue *prototype = scopeObject->prototype(_context);
- while (prototype) {
+ PrototypeIterator iter(scopeObject, _context);
+ iter.next();
+ while (iter.hasNext()) {
+ const ObjectValue *prototype = iter.next();
if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) {
if ((qmlMetaObject->className() == QLatin1String("ListElement")
|| qmlMetaObject->className() == QLatin1String("Connections")
@@ -213,11 +215,10 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
break;
}
}
- prototype = prototype->prototype(_context);
}
// check if the object has a Qt.PropertyChanges ancestor
- prototype = scopeObject->prototype(_context);
+ const ObjectValue *prototype = scopeObject->prototype(_context);
prototype = isPropertyChangesObject(_context, prototype);
// find the target script binding
if (prototype) {
@@ -281,15 +282,15 @@ const Value *ScopeBuilder::scopeObjectLookup(AST::UiQualifiedId *id)
const ObjectValue *ScopeBuilder::isPropertyChangesObject(const Context *context,
const ObjectValue *object)
{
- const ObjectValue *prototype = object;
- while (prototype) {
+ PrototypeIterator iter(object, context);
+ while (iter.hasNext()) {
+ const ObjectValue *prototype = iter.next();
if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) {
if (qmlMetaObject->className() == QLatin1String("PropertyChanges")
&& (qmlMetaObject->packageName() == QLatin1String("Qt")
|| qmlMetaObject->packageName() == QLatin1String("QtQuick")))
return prototype;
}
- prototype = prototype->prototype(context);
}
return 0;
}