From bf3a1660a556d8efa595f4494b152af96a2b5ef9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Jul 2017 21:42:43 +0200 Subject: [PATCH] rename handleMissingProperty to handleChangedPropertyName --- src/App/PropertyContainer.cpp | 34 ++++++++++++++++++++++------------ src/App/PropertyContainer.h | 3 +-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index ebce3ace32..8251d69d35 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -153,17 +153,22 @@ const PropertyData * PropertyContainer::getPropertyDataPtr(void){return &propert const PropertyData & PropertyContainer::getPropertyData(void) const{return propertyData;} /** - * @brief PropertyContainer::handleMissingProperty is called during restore to possibly - * fix reading of older versions of this property container. + * @brief PropertyContainer::handleChangedPropertyName is called during restore to possibly + * fix reading of older versions of this property container. This method is typically called + * if the property on file has changed its name in more recent versions. * * The default implementation does nothing. * * @param reader The XML stream to read from. + * @param TypeName Name of property type on file. * @param PropName Name of property on file that does not exist in the container anymore. */ -void PropertyContainer::handleMissingProperty(XMLReader &reader, const char *PropName) +void PropertyContainer::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) { + (void)reader; + (void)TypeName; + (void)PropName; } /** @@ -180,6 +185,9 @@ void PropertyContainer::handleMissingProperty(XMLReader &reader, const char *Pro void PropertyContainer::handleChangedPropertyType(XMLReader &reader, const char *TypeName, Property *prop) { + (void)reader; + (void)TypeName; + (void)prop; } PropertyData PropertyContainer::propertyData; @@ -264,16 +272,18 @@ void PropertyContainer::Restore(Base::XMLReader &reader) // not its name. In this case we would force to read-in a wrong property // type and the behaviour would be undefined. try { - - // Property not found in container, but one file? - if (!prop) - handleMissingProperty(reader, PropName); + // name and type match + if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) { + prop->Restore(reader); + } + // name matches but not the type + else if (prop) { + handleChangedPropertyType(reader, TypeName, prop); + } + // name doesn't match, the sub-class then has to know + // if the property has been renamed or removed else { - // Has the type changed? - if (strcmp(prop->getTypeId().getName(), TypeName) != 0) - handleChangedPropertyType(reader, TypeName, prop); - else - prop->Restore(reader); // All as before + handleChangedPropertyName(reader, TypeName, PropName); } } catch (const Base::XMLParseException&) { diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index 752f20b342..bbd716bfd8 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -196,8 +196,7 @@ protected: static const PropertyData * getPropertyDataPtr(void); virtual const PropertyData& getPropertyData(void) const; - virtual void handleMissingProperty(Base::XMLReader &reader, const char *PropName); - + virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop); private: