From d7dd720eaf2de5b61e9d69a1951744561e56cef7 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 8 Aug 2019 22:13:41 +0800 Subject: [PATCH] App: fix property type matching in transaction --- src/App/Transactions.cpp | 13 +++++++++---- src/App/Transactions.h | 7 ++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 9c1af58038..32270607f8 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -335,11 +335,11 @@ void TransactionObject::applyChn(Document & /*Doc*/, TransactionalObject *pcObj, } // Because we now allow undo/redo dynamic property adding/removing, // we have to enforce property type checking before calling Copy/Paste. - if(data.property->getTypeId() != prop->getTypeId()) { + if(data.propertyType != prop->getTypeId()) { FC_WARN("Cannot " << (Forward?"redo":"undo") << " change of property " << prop->getName() << " because of type change: " - << data.property->getTypeId().getName() + << data.propertyType.getName() << " -> " << prop->getTypeId().getName()); continue; } @@ -352,8 +352,10 @@ void TransactionObject::setProperty(const Property* pcProp) { auto &data = _PropChangeMap[pcProp]; if(!data.property && data.name.empty()) { - data = pcProp->getContainer()->getDynamicPropertyData(pcProp); + static_cast(data) = + pcProp->getContainer()->getDynamicPropertyData(pcProp); data.property = pcProp->Copy(); + data.propertyType = pcProp->getTypeId(); data.property->setStatusValue(pcProp->getStatus()); } } @@ -377,11 +379,14 @@ void TransactionObject::addOrRemoveProperty(const Property* pcProp, bool add) delete data.property; data.property = 0; } - data = pcProp->getContainer()->getDynamicPropertyData(pcProp); + + static_cast(data) = + pcProp->getContainer()->getDynamicPropertyData(pcProp); if(add) data.property = 0; else { data.property = pcProp->Copy(); + data.propertyType = pcProp->getTypeId(); data.property->setStatusValue(pcProp->getStatus()); } } diff --git a/src/App/Transactions.h b/src/App/Transactions.h index 135544c90c..ff14e1e30b 100644 --- a/src/App/Transactions.h +++ b/src/App/Transactions.h @@ -128,7 +128,12 @@ public: protected: enum Status {New,Del,Chn} status; - std::unordered_map _PropChangeMap; + + struct PropData : DynamicProperty::PropData { + Base::Type propertyType; + }; + std::unordered_map _PropChangeMap; + std::string _NameInDocument; };