From dcd7da480a926d0b0d44f633ab56755aaa6ced54 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 9 Sep 2017 22:47:28 +0200 Subject: [PATCH] support of loading old projects with shape binder or PartDesign boolean --- src/App/PropertyLinks.cpp | 4 ++-- src/Mod/PartDesign/App/FeatureBoolean.cpp | 9 +++++++++ src/Mod/PartDesign/App/FeatureBoolean.h | 3 +++ src/Mod/PartDesign/App/ShapeBinder.cpp | 8 ++++++++ src/Mod/PartDesign/App/ShapeBinder.h | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index ee520be8bd..30ddd6838c 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -939,8 +939,8 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader) // referenced objects in XML which do not exist anymore in the new // document. Thus, we should silently ignore this. // Property not in an object! - DocumentObject* father = static_cast(getContainer()); - App::Document* document = father->getDocument(); + DocumentObject* father = dynamic_cast(getContainer()); + App::Document* document = father ? father->getDocument() : 0; DocumentObject* child = document ? document->getObject(name.c_str()) : 0; if (child) values.push_back(child); diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index bc0a6c68ee..b0c58855c8 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -149,4 +149,13 @@ void Boolean::onChanged(const App::Property* prop) { PartDesign::Feature::onChanged(prop); } +void Boolean::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) +{ + // The App::PropertyLinkList property was Bodies in the past + Base::Type type = Base::Type::fromName(TypeName); + if (Group.getClassTypeId() == type && strcmp(PropName, "Bodies") == 0) { + Group.Restore(reader); + } +} + } diff --git a/src/Mod/PartDesign/App/FeatureBoolean.h b/src/Mod/PartDesign/App/FeatureBoolean.h index 61e2a21a6e..d38a0fe0c8 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.h +++ b/src/Mod/PartDesign/App/FeatureBoolean.h @@ -58,6 +58,9 @@ public: virtual void onChanged(const App::Property* prop); //@} +protected: + void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); + private: static const char* TypeEnums[]; diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 3d46c85cb9..f1687779e8 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -149,3 +149,11 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences( Part::Feature* obj, std:: } return base; } + +void ShapeBinder::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + // The type of Support was App::PropertyLinkSubList in the past + if (prop == &Support && strcmp(TypeName, "App::PropertyLinkSubList") == 0) { + Support.Restore(reader); + } +} diff --git a/src/Mod/PartDesign/App/ShapeBinder.h b/src/Mod/PartDesign/App/ShapeBinder.h index d8f5056418..36afb524cb 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.h +++ b/src/Mod/PartDesign/App/ShapeBinder.h @@ -57,6 +57,7 @@ public: } protected: + virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); virtual short int mustExecute(void) const; virtual App::DocumentObjectExecReturn* execute(void); };