diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-11-03 04:17:31 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-11-03 22:54:50 (GMT) |
commit | afcbf6a97744a7b113dc5ce542618a5543aead91 (patch) | |
tree | 98f328ff716114579be5755c7ce1948f39566a4f /src/declarative/qml | |
parent | 356fe6a0474c07dc6dd8ffd9b52f1e2060e3a450 (diff) | |
download | Qt-afcbf6a97744a7b113dc5ce542618a5543aead91.zip Qt-afcbf6a97744a7b113dc5ce542618a5543aead91.tar.gz Qt-afcbf6a97744a7b113dc5ce542618a5543aead91.tar.bz2 |
Avoid crashing on faulty call to createQmlObject
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c562e02..29d91bc 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -625,6 +625,11 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi url = QUrl(ctxt->argument(2).toString()); QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); QmlContext *qmlCtxt = qmlContext(parentArg); + if(!parentArg || !qmlCtxt){ + //TODO: Could use a qmlInfo() like function for script functions + qWarning() << "createQmlObject called with invalid parent object"; + return engine->nullValue(); + } if (url.isEmpty()) { url = qmlCtxt->resolvedUrl(QUrl(QLatin1String("<Unknown File>"))); } else { |