QmlDesigner: Fix update of effects after initial drag from library

Effect source type was set to incorrect after the initial drag to the
scene, so even resetting puppet wouldn't make a newly added effect
show up. Fixed by updating the NodeSourceType when updating the node
source.

Also reset the puppet for now when node source changes, as it doesn't
handle source changes properly.

Change-Id: Id22a298738fb1e7f841b94b473ccb61cc82e0322
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2021-08-27 16:23:52 +03:00
parent d96d9c1f3d
commit 1d5ddbf8f8
4 changed files with 22 additions and 2 deletions

View File

@@ -226,6 +226,7 @@ public:
qint32 internalId() const;
void setNodeSource(const QString&);
void setNodeSource(const QString &newNodeSource, NodeSourceType type);
QString nodeSource() const;
QString convertTypeToImportAlias() const;

View File

@@ -642,6 +642,9 @@ void NodeInstanceView::nodeSourceChanged(const ModelNode &node, const QString &
NodeInstance instance = instanceForModelNode(node);
ChangeNodeSourceCommand changeNodeSourceCommand(instance.instanceId(), newNodeSource);
m_nodeInstanceServer->changeNodeSource(changeNodeSourceCommand);
// Puppet doesn't deal with node source changes properly, so just reset the puppet for now
delayedRestartProcess(); // TODO: Remove this once the issue is properly fixed (QDS-4955)
}
}

View File

@@ -1278,6 +1278,22 @@ void ModelNode::setNodeSource(const QString &newNodeSource)
m_model.data()->d->setNodeSource(internalNode(), newNodeSource);
}
void ModelNode::setNodeSource(const QString &newNodeSource, NodeSourceType type)
{
Internal::WriteLocker locker(m_model.data());
if (!isValid()) {
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid");
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
}
if (internalNode()->nodeSourceType() == type && internalNode()->nodeSource() == newNodeSource)
return;
internalNode()->setNodeSourceType(type); // Set type first as it doesn't trigger any notifies
m_model.data()->d->setNodeSource(internalNode(), newNodeSource);
}
QString ModelNode::nodeSource() const
{
if (!isValid())

View File

@@ -2086,7 +2086,7 @@ void TextToModelMerger::setupComponent(const ModelNode &node)
return; //No object definition found
if (node.nodeSource() != result)
ModelNode(node).setNodeSource(result);
ModelNode(node).setNodeSource(result, ModelNode::NodeWithComponentSource);
}
void TextToModelMerger::collectLinkErrors(QList<DocumentMessage> *errors, const ReadingContext &ctxt)
@@ -2256,7 +2256,7 @@ void TextToModelMerger::setupCustomParserNode(const ModelNode &node)
return;
if (node.nodeSource() != modelText)
ModelNode(node).setNodeSource(modelText);
ModelNode(node).setNodeSource(modelText, ModelNode::NodeWithCustomParserSource);
}