App: report error on copying OriginGroup without dependency
This commit is contained in:
@@ -193,8 +193,9 @@ void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) {
|
||||
//objects are only allowed in a single GeoFeatureGroup
|
||||
if(p == &Group && !Group.testStatus(Property::User3)) {
|
||||
|
||||
if(!getExtendedObject()->isRestoring() &&
|
||||
!getExtendedObject()->getDocument()->isPerformingTransaction()) {
|
||||
if((!getExtendedObject()->isRestoring()
|
||||
|| getExtendedObject()->getDocument()->testStatus(Document::Importing))
|
||||
&& !getExtendedObject()->getDocument()->isPerformingTransaction()) {
|
||||
|
||||
bool error = false;
|
||||
auto corrected = Group.getValues();
|
||||
|
||||
@@ -149,6 +149,26 @@ void OriginGroupExtension::onExtendedUnsetupObject () {
|
||||
GeoFeatureGroupExtension::onExtendedUnsetupObject ();
|
||||
}
|
||||
|
||||
void OriginGroupExtension::extensionOnChanged(const Property* p) {
|
||||
if(p == &Origin) {
|
||||
App::DocumentObject *owner = getExtendedObject();
|
||||
App::DocumentObject *origin = Origin.getValue();
|
||||
// Document::Importing indicats the object is being imported (i.e.
|
||||
// copied). So check the Origin ownership here to prevent copy without
|
||||
// dependency
|
||||
if (origin && owner && owner->getDocument()
|
||||
&& owner->getDocument()->testStatus(Document::Importing)) {
|
||||
for (auto o : origin->getInList()) {
|
||||
if(o != owner && o->hasExtension(App::OriginGroupExtension::getExtensionClassTypeId())) {
|
||||
Origin.setValue(nullptr);
|
||||
throw Base::RuntimeError("Origin can only be in a single OriginGroup");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GeoFeatureGroupExtension::extensionOnChanged(p);
|
||||
}
|
||||
|
||||
void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
|
||||
{
|
||||
//we get all links and replace the origin objects if needed (subnames need not to change, they
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
virtual bool extensionGetSubObject(DocumentObject *&ret, const char *subname, PyObject **pyObj,
|
||||
Base::Matrix4D *mat, bool transform, int depth) const override;
|
||||
|
||||
virtual void extensionOnChanged(const Property* p) override;
|
||||
|
||||
protected:
|
||||
/// Checks integrity of the Origin
|
||||
virtual App::DocumentObjectExecReturn *extensionExecute () override;
|
||||
|
||||
Reference in New Issue
Block a user