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.
This commit is contained in:
@@ -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<App::GeoFeatureGroupExtension>()->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<App::GeoFeatureGroupExtension>()->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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user