Commit 981ce880 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: fixes crash in nodeinstances

There was a subtle bug in propertyReseting() that caused a gradient
property of a Rectangle not to be removed, if the gradient was deleted.
Deleting the gradient triggered a reparenting operation in the
nodeinstances where the resetProperty() of the oldParent was not
executed properly.

This caused a dangling pointer in QDeclarativeRectangle.

Reviewed-by: Marco Bubke
parent 4ca6422b
......@@ -153,7 +153,6 @@ void NodeInstanceView::nodeAboutToBeRemoved(const ModelNode &removedNode)
void NodeInstanceView::nodeRemoved(const ModelNode &/*removedNode*/, const NodeAbstractProperty &/*parentProperty*/, PropertyChangeFlags /*propertyChange*/)
{
}
/*! \brief Notifing the view that a AbstractProperty was added to a ModelNode.
......
......@@ -375,7 +375,9 @@ void ObjectNodeInstance::removeFromOldProperty(QObject *object, QObject *oldPare
if (isList(metaProperty)) {
removeObjectFromList(metaProperty, object, nodeInstanceView()->engine());
} else if (isObject(metaProperty)) {
resetProperty(object, oldParentProperty);
if (nodeInstanceView()->hasInstanceForObject(oldParent)) {
nodeInstanceView()->instanceForObject(oldParent).resetProperty(oldParentProperty);
}
}
object->setParent(0);
......@@ -500,13 +502,13 @@ void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &metaPro
void ObjectNodeInstance::resetProperty(const QString &name)
{
resetProperty(object(), name);
doResetProperty(name);
if (name == "font.pixelSize")
resetProperty(object(), "font.pointSize");
doResetProperty("font.pointSize");
if (name == "font.pointSize")
resetProperty(object(), "font.pixelSize");
doResetProperty("font.pixelSize");
}
NodeInstance ObjectNodeInstance::instanceForNode(const ModelNode &node, const QString &fullname)
......@@ -543,11 +545,11 @@ void ObjectNodeInstance::refreshProperty(const QString &name)
property.write(oldValue);
}
void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyName)
void ObjectNodeInstance::doResetProperty(const QString &propertyName)
{
m_modelAbstractPropertyHash.remove(propertyName);
QDeclarativeProperty metaProperty(object, propertyName, context());
QDeclarativeProperty metaProperty(object(), propertyName, context());
if (!metaProperty.isValid())
return;
......@@ -557,7 +559,7 @@ void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyN
QUrl url = oldValue.toUrl();
QString path = url.toLocalFile();
if (QFileInfo(path).exists() && nodeInstanceView())
nodeInstanceView()->removeFilePropertyFromFileSystemWatcher(object, propertyName, path);
nodeInstanceView()->removeFilePropertyFromFileSystemWatcher(object(), propertyName, path);
}
......
......@@ -171,7 +171,7 @@ public:
protected:
static QObject* createObject(const NodeMetaInfo &metaInfo, QDeclarativeContext *context);
void resetProperty(QObject *object, const QString &propertyName);
void doResetProperty(const QString &propertyName);
NodeInstance instanceForNode(const ModelNode &node, const QString &fullname);
void removeFromOldProperty(QObject *object, QObject *oldParent, const QString &oldParentProperty);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment