From afcbf6a97744a7b113dc5ce542618a5543aead91 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 3 Nov 2009 14:17:31 +1000 Subject: Avoid crashing on faulty call to createQmlObject --- src/declarative/qml/qmlengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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(""))); } else { -- cgit v0.12