@@ -152,6 +152,36 @@ const char* PropertyContainer::getPropertyName(const Property* prop)const
152
152
const PropertyData * PropertyContainer::getPropertyDataPtr (void ){return &propertyData;}
153
153
const PropertyData & PropertyContainer::getPropertyData (void ) const {return propertyData;}
154
154
155
+ /* *
156
+ * @brief PropertyContainer::handleMissingProperty is called during restore to possibly
157
+ * fix reading of older versions of this property container.
158
+ *
159
+ * The default implementation does nothing.
160
+ *
161
+ * @param reader The XML stream to read from.
162
+ * @param PropName Name of property on file that does not exist in the container anymore.
163
+ */
164
+
165
+ void PropertyContainer::handleMissingProperty (XMLReader &reader, const char *PropName)
166
+ {
167
+ }
168
+
169
+ /* *
170
+ * @brief PropertyContainer::handleChangedPropertyType is called during restore to possibly
171
+ * fix reading of older versions of the property container. This method is typically called
172
+ * if the property on file has changed its type in more recent versions.
173
+ *
174
+ * The default implementation does nothing.
175
+ *
176
+ * @param reader The XML stream to read from.
177
+ * @param TypeName Name of property type on file.
178
+ * @param prop Pointer to property to restore. Its type differs from TypeName.
179
+ */
180
+
181
+ void PropertyContainer::handleChangedPropertyType (XMLReader &reader, const char *TypeName, Property *prop)
182
+ {
183
+ }
184
+
155
185
PropertyData PropertyContainer::propertyData;
156
186
157
187
/* *
@@ -234,8 +264,17 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
234
264
// not its name. In this case we would force to read-in a wrong property
235
265
// type and the behaviour would be undefined.
236
266
try {
237
- if (prop && strcmp (prop->getTypeId ().getName (), TypeName) == 0 )
238
- prop->Restore (reader);
267
+
268
+ // Property not found in container, but one file?
269
+ if (!prop)
270
+ handleMissingProperty (reader, PropName);
271
+ else {
272
+ // Has the type changed?
273
+ if (strcmp (prop->getTypeId ().getName (), TypeName) != 0 )
274
+ handleChangedPropertyType (reader, TypeName, prop);
275
+ else
276
+ prop->Restore (reader); // All as before
277
+ }
239
278
}
240
279
catch (const Base::XMLParseException&) {
241
280
throw ; // re-throw
0 commit comments