From 980e95ce0541cf74791cedbc94cf7146232fb762 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 14 Mar 2018 18:05:24 +0100 Subject: [PATCH] fix Debian bug #825861 --- src/Mod/Part/App/Part2DObject.cpp | 72 +++++++---------------- src/Mod/Part/App/Part2DObject.h | 4 ++ src/Mod/Part/Gui/ViewProvider2DObject.cpp | 58 +++++------------- src/Mod/Part/Gui/ViewProvider2DObject.h | 1 + 4 files changed, 41 insertions(+), 94 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index cfaaa18047..c0db988df7 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -214,60 +214,32 @@ void Part2DObject::acceptGeometry() } void Part2DObject::Restore(Base::XMLReader &reader) +{ + Part::Feature::Restore(reader); +} + +void Part2DObject::handleChangedPropertyType(Base::XMLReader &reader, + const char * TypeName, + App::Property * prop) { //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())){ - //reading legacy Support - when the Support could only be a single flat face. - App::PropertyLinkSub tmp; - if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) { - tmp.setContainer(this); - tmp.Restore(reader); - static_cast(prop)->setValue(tmp.getValue(), tmp.getSubValues()); - } - this->MapMode.setValue(Attacher::mmFlatFace); - } - } else { - extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension - } + if (prop->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) { + //reading legacy Support - when the Support could only be a single flat face. + App::PropertyLinkSub tmp; + if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) { + tmp.setContainer(this); + tmp.Restore(reader); + static_cast(prop)->setValue(tmp.getValue(), tmp.getSubValues()); } - 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"); + this->MapMode.setValue(Attacher::mmFlatFace); } - reader.readEndElement("Properties"); +} + +void Part2DObject::handleChangedPropertyName(Base::XMLReader &reader, + const char * TypeName, + const char *PropName) +{ + extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension } // Python Drawing feature --------------------------------------------------------- diff --git a/src/Mod/Part/App/Part2DObject.h b/src/Mod/Part/App/Part2DObject.h index 12c16b3e6f..a5483678ee 100644 --- a/src/Mod/Part/App/Part2DObject.h +++ b/src/Mod/Part/App/Part2DObject.h @@ -94,6 +94,10 @@ public: //@} void Restore(Base::XMLReader &reader); + +protected: + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); + void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); }; typedef App::FeaturePythonT Part2DObjectPython; diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp index 5cd3f131fe..edaa3c8cd2 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp +++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp @@ -263,52 +263,22 @@ void ViewProvider2DObject::onChanged(const App::Property* prop) void ViewProvider2DObject::Restore(Base::XMLReader &reader) { - reader.readElement("Properties"); - int Cnt = reader.getAttributeAsInteger("Count"); + ViewProviderPart::Restore(reader); +} - for (int i=0 ;igetTypeId().getName(), TypeName) == 0) { - prop->Restore(reader); - } - else if (prop) { - Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && - inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - // Do not directly call the property's Restore method in case the implementation - // has changed. So, create a temporary PropertyFloat object and assign the value. - App::PropertyFloat floatProp; - floatProp.Restore(reader); - static_cast(prop)->setValue(floatProp.getValue()); - } - } - } - 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("Primitive::Restore: Unknown C++ exception thrown"); - } -#endif - - reader.readEndElement("Property"); +void ViewProvider2DObject::handleChangedPropertyType(Base::XMLReader &reader, + const char * TypeName, + App::Property * prop) +{ + Base::Type inputType = Base::Type::fromName(TypeName); + if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + // Do not directly call the property's Restore method in case the implementation + // has changed. So, create a temporary PropertyFloat object and assign the value. + App::PropertyFloat floatProp; + floatProp.Restore(reader); + static_cast(prop)->setValue(floatProp.getValue()); } - reader.readEndElement("Properties"); } void ViewProvider2DObject::attach(App::DocumentObject *pcFeat) diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.h b/src/Mod/Part/Gui/ViewProvider2DObject.h index a68ffaf9e9..f6662c771d 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.h +++ b/src/Mod/Part/Gui/ViewProvider2DObject.h @@ -68,6 +68,7 @@ protected: /// get called by the container whenever a property has been changed virtual void onChanged(const App::Property* prop); virtual void Restore(Base::XMLReader &reader); + virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); SoSeparator *GridRoot;