summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/globalobject.qdoc4
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp8
2 files changed, 7 insertions, 5 deletions
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 6709ab4..57eaae7 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -223,7 +223,7 @@ of their use.
function finishCreation(){
if(component.isReady()){
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
}else{
sprite.parent = page;
@@ -248,7 +248,7 @@ of their use.
\code
component = createComponent("Sprite.qml");
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
console.log(component.errorsString());
}else{
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 24edf7d..161ce56 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -594,7 +594,9 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
/*!
\qmlmethod object Component::createObject()
- Returns an object instance from this component.
+ Returns an object instance from this component, or null if object creation fails.
+
+ The object will be created in the same context as the component was created in.
*/
/*!
@@ -606,10 +608,10 @@ QScriptValue QDeclarativeComponent::createObject()
Q_D(QDeclarativeComponent);
QDeclarativeContext* ctxt = creationContext();
if(!ctxt)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QObject* ret = create(ctxt);
if (!ret)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
QDeclarativeData::get(ret, true)->setImplicitDestructible();
return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);