diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 9a6c34141..5dea4b36b 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -233,18 +233,9 @@ void PropertyContainer::Restore(Base::XMLReader &reader) // subclass of PropertyContainer might change the type of a property but // not its name. In this case we would force to read-in a wrong property // type and the behaviour would be undefined. - // Exception: PropertyLinkSubList can read PropertyLinkSub try { - if(prop){ - if (strcmp(prop->getTypeId().getName(), TypeName) == 0){ - prop->Restore(reader); - } else if (prop->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())){ - App::PropertyLinkSub tmp;//getTypeId() is not static =( - if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) { - static_cast(prop)->Restore_FromLinkSub(reader); - } - } - } + if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) + prop->Restore(reader); } catch (const Base::XMLParseException&) { throw; // re-throw diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 2d27f7564..22cd97ef8 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -45,7 +45,10 @@ #include +#include #include +#include +#include #include "Part2DObject.h" #include "Geometry.h" #include "DatumFeature.h" @@ -208,6 +211,58 @@ void Part2DObject::acceptGeometry() // implemented in sub-classes } +void Part2DObject::Restore(Base::XMLReader &reader) +{ + //override generic restoration to convert Support property from PropertyLinkSub to PropertyLinkSubList + + reader.readElement("Properties"); + int Cnt = reader.getAttributeAsInteger("Count"); + + for (int i=0 ;igetTypeId().getName(), TypeName) == 0){ + prop->Restore(reader); + } else if (prop->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())){ + App::PropertyLinkSub tmp;//getTypeId() is not static =( + if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) { + static_cast(prop)->Restore_FromLinkSub(reader); + } + } + } + } + catch (const Base::XMLParseException&) { + throw; // re-throw + } + catch (const Base::Exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const std::exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const char* e) { + Base::Console().Error("%s\n", e); + } +#ifndef FC_DEBUG + catch (...) { + Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown"); + } +#endif + + reader.readEndElement("Property"); + } + reader.readEndElement("Properties"); +} + // Python Drawing feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/Part/App/Part2DObject.h b/src/Mod/Part/App/Part2DObject.h index c37c31d37..9041ebb97 100644 --- a/src/Mod/Part/App/Part2DObject.h +++ b/src/Mod/Part/App/Part2DObject.h @@ -93,6 +93,7 @@ public: } //@} + void Restore(Base::XMLReader &reader); }; typedef App::FeaturePythonT Part2DObjectPython;