summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljsscopebuilder.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-05-19 14:22:02 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-05-19 14:23:08 +0200
commit62141475e35428a5545a686a1e3e5e9238d3288e (patch)
tree3b644673bdca1bfa436e5d41e98811e843532e93 /src/libs/qmljs/qmljsscopebuilder.cpp
parent56d0e4f31748e1d74661bd315a5968e0b0919be3 (diff)
downloadqt-creator-62141475e35428a5545a686a1e3e5e9238d3288e.tar.gz
QmlJS: Potentially fix hard-to-reproduce crash in JS completion.
* Context::build was potentially dangerous. Link and ScopeBuilder went out of scope before their results stopped being used. * ScopeBuilder: If no function scope object was found, don't add it. Reviewed-by: Erik Verbruggen
Diffstat (limited to 'src/libs/qmljs/qmljsscopebuilder.cpp')
-rw-r--r--src/libs/qmljs/qmljsscopebuilder.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp
index 80b3fbb7d7..2cc24a8cd5 100644
--- a/src/libs/qmljs/qmljsscopebuilder.cpp
+++ b/src/libs/qmljs/qmljsscopebuilder.cpp
@@ -33,7 +33,8 @@ void ScopeBuilder::push(AST::Node *node)
// JS scopes
if (FunctionDeclaration *fun = cast<FunctionDeclaration *>(node)) {
ObjectValue *functionScope = _doc->bind()->findFunctionScope(fun);
- _context->scopeChain().jsScopes += functionScope;
+ if (functionScope)
+ _context->scopeChain().jsScopes += functionScope;
}
_context->scopeChain().update();