diff options
-rw-r--r-- | src/declarative/qml/qdeclarativecomponent.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 3f11425..3b782e7 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -576,10 +576,12 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent) bool needParent = (gobj != 0); if(parent){ ret->setParent(parent); - QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent); - if(gparent){ - gobj->setParentItem(gparent); - needParent = false; + if (gobj) { + QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent); + if(gparent){ + gobj->setParentItem(gparent); + needParent = false; + } } } if(needParent) |