From ca745449598223013c5c970ebaea370fc270dfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Mon, 18 Sep 2017 09:57:35 +0200 Subject: [PATCH] Don't check for multiple groups when performing a transaction. fixes #0003150 During undo/redo the order in which objects are removed from a group and added to annother is arbitrary, hence it cannot comply to the single Group rule. Not echking for it in this case is unproblematic, as undo/redo only recrete former states, and those states have been checked in normal operation. --- src/App/GeoFeatureGroupExtension.cpp | 39 +++++++++++++++------------- src/App/GroupExtension.cpp | 35 +++++++++++++------------ 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index d31aab5390..68d1ba2fa2 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -189,28 +189,31 @@ void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) { //objects are only allowed in a single GeoFeatureGroup if((strcmp(p->getName(), "Group")==0)) { + + if(!getExtendedObject()->getDocument()->isPerformingTransaction()) { + + bool error = false; + auto corrected = Group.getValues(); + for(auto obj : Group.getValues()) { - bool error = false; - auto corrected = Group.getValues(); - for(auto obj : Group.getValues()) { - - //we have already set the obj into the group, so in a case of multiple groups getGroupOfObject - //would return anyone of it and hence it is possible that we miss an error. We need a custom check - auto list = obj->getInList(); - for (auto in : list) { - if(in->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()) && //is GeoFeatureGroup? - in != getExtendedObject() && //is a different one? - in->getExtensionByType()->hasObject(obj)) { //is not a non-grouping link? - error = true; - corrected.erase(std::remove(corrected.begin(), corrected.end(), obj), corrected.end()); + //we have already set the obj into the group, so in a case of multiple groups getGroupOfObject + //would return anyone of it and hence it is possible that we miss an error. We need a custom check + auto list = obj->getInList(); + for (auto in : list) { + if(in->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()) && //is GeoFeatureGroup? + in != getExtendedObject() && //is a different one? + in->getExtensionByType()->hasObject(obj)) { //is not a non-grouping link? + error = true; + corrected.erase(std::remove(corrected.begin(), corrected.end(), obj), corrected.end()); + } } } - } - //if an error was found we need to correct the values and inform the user - if(error) { - Group.setValues(corrected); - throw Base::Exception("Object can only be in a single GeoFeatureGroup"); + //if an error was found we need to correct the values and inform the user + if(error) { + Group.setValues(corrected); + throw Base::Exception("Object can only be in a single GeoFeatureGroup"); + } } } diff --git a/src/App/GroupExtension.cpp b/src/App/GroupExtension.cpp index ec9b56edec..eee5a51c12 100644 --- a/src/App/GroupExtension.cpp +++ b/src/App/GroupExtension.cpp @@ -305,26 +305,29 @@ void GroupExtension::extensionOnChanged(const Property* p) { if((this->getExtensionTypeId() == GroupExtension::getExtensionClassTypeId()) && (strcmp(p->getName(), "Group")==0)) { - bool error = false; - auto corrected = Group.getValues(); - for(auto obj : Group.getValues()) { + if(!getExtendedObject()->getDocument()->isPerformingTransaction()) { + + bool error = false; + auto corrected = Group.getValues(); + for(auto obj : Group.getValues()) { - //we have already set the obj into the group, so in a case of multiple groups getGroupOfObject - //would return anyone of it and hence it is possible that we miss an error. We need a custom check - auto list = obj->getInList(); - for (auto in : list) { - if(in->hasExtension(App::GroupExtension::getExtensionClassTypeId(), false) && - in != getExtendedObject()) { - error = true; - corrected.erase(std::remove(corrected.begin(), corrected.end(), obj), corrected.end()); + //we have already set the obj into the group, so in a case of multiple groups getGroupOfObject + //would return anyone of it and hence it is possible that we miss an error. We need a custom check + auto list = obj->getInList(); + for (auto in : list) { + if(in->hasExtension(App::GroupExtension::getExtensionClassTypeId(), false) && + in != getExtendedObject()) { + error = true; + corrected.erase(std::remove(corrected.begin(), corrected.end(), obj), corrected.end()); + } } } - } - //if an error was found we need to correct the values and inform the user - if(error) { - Group.setValues(corrected); - throw Base::Exception("Object can only be in a single Group"); + //if an error was found we need to correct the values and inform the user + if(error) { + Group.setValues(corrected); + throw Base::Exception("Object can only be in a single Group"); + } } }