forked from qt-creator/qt-creator
QmlDesigner: Avoid reflection when setting values from puppet
When editing values in the puppet we did not take reflection into account. This means that any changes we did from the puppet for notified back from Qt Creator. Since those notifications are asynchronous this leads to various issues especially when more than one axis (property) was modified at once. This patch avoids reflection. The notifications are 'flagged' and then ignored in the Qt5InformationNodeInstanceServer. While a node is moved we ignore any changes to that specific node. Task-number: QDS-1191 Change-Id: Ic74e22ea71832ce12321f9085a7296c2a7d9893d Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -396,6 +396,11 @@ void ObjectNodeInstance::setHideInEditor(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::setModifiedFlag(bool b)
|
||||
{
|
||||
m_isModified = b;
|
||||
}
|
||||
|
||||
QVariant ObjectNodeInstance::convertEnumToValue(const QVariant &value, const PropertyName &name)
|
||||
{
|
||||
Q_ASSERT(value.canConvert<Enumeration>());
|
||||
@@ -420,6 +425,9 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
|
||||
if (ignoredProperties().contains(name))
|
||||
return;
|
||||
|
||||
if (m_isModified)
|
||||
return;
|
||||
|
||||
QQmlProperty property(object(), QString::fromUtf8(name), context());
|
||||
|
||||
if (!property.isValid())
|
||||
|
||||
@@ -195,6 +195,8 @@ public:
|
||||
|
||||
void virtual setHideInEditor(bool b);
|
||||
|
||||
void setModifiedFlag(bool b);
|
||||
|
||||
protected:
|
||||
explicit ObjectNodeInstance(QObject *object);
|
||||
void doResetProperty(const PropertyName &propertyName);
|
||||
@@ -220,6 +222,7 @@ private:
|
||||
qint32 m_instanceId;
|
||||
bool m_deleteHeldInstance;
|
||||
bool m_isInLayoutable;
|
||||
bool m_isModified = false;
|
||||
static QHash<EnumerationName, QVariant> m_enumationValueHash;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "changeselectioncommand.h"
|
||||
#include "objectnodeinstance.h"
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
#include "../editor3d/cameracontrolhelper.h"
|
||||
@@ -166,10 +167,18 @@ void Qt5InformationNodeInstanceServer::modifyVariantValue(
|
||||
targetPopertyName = propertyName;
|
||||
|
||||
auto *obj = node.value<QObject *>();
|
||||
|
||||
if (obj) {
|
||||
ServerNodeInstance instance = instanceForObject(obj);
|
||||
|
||||
if (option == ValuesModifiedCommand::TransactionOption::Start)
|
||||
instance.setModifiedFlag(true);
|
||||
else if (option == ValuesModifiedCommand::TransactionOption::End)
|
||||
instance.setModifiedFlag(false);
|
||||
|
||||
// We do have to split position into position.x, position.y, position.z
|
||||
ValuesModifiedCommand command = createValuesModifiedCommand(vectorToPropertyValue(
|
||||
instanceForObject(obj),
|
||||
instance,
|
||||
targetPopertyName,
|
||||
obj->property(propertyName)));
|
||||
|
||||
@@ -539,4 +548,21 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
|
||||
}
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command)
|
||||
{
|
||||
bool hasDynamicProperties = false;
|
||||
const QVector<PropertyValueContainer> values = command.valueChanges();
|
||||
for (const PropertyValueContainer &container : values) {
|
||||
if (!container.isReflected()) {
|
||||
hasDynamicProperties |= container.isDynamic();
|
||||
setInstancePropertyVariant(container);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDynamicProperties)
|
||||
refreshBindings();
|
||||
|
||||
startRenderTimer();
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
void token(const TokenCommand &command) override;
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
void changePropertyValues(const ChangeValuesCommand &command) override;
|
||||
|
||||
private slots:
|
||||
void objectClicked(const QVariant &object);
|
||||
|
||||
@@ -129,6 +129,11 @@ bool ServerNodeInstance::isSubclassOf(QObject *object, const QByteArray &superTy
|
||||
return Internal::QmlPrivateGate::isSubclassOf(object, superTypeName);
|
||||
}
|
||||
|
||||
void ServerNodeInstance::setModifiedFlag(bool b)
|
||||
{
|
||||
m_nodeInstance->setModifiedFlag(b);
|
||||
}
|
||||
|
||||
void ServerNodeInstance::setNodeSource(const QString &source)
|
||||
{
|
||||
m_nodeInstance->setNodeSource(source);
|
||||
|
||||
@@ -165,6 +165,8 @@ public:
|
||||
|
||||
static bool isSubclassOf(QObject *object, const QByteArray &superTypeName);
|
||||
|
||||
void setModifiedFlag(bool b);
|
||||
|
||||
private: // functions
|
||||
ServerNodeInstance(const QSharedPointer<Internal::ObjectNodeInstance> &abstractInstance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user