diff --git a/Documentation/release/dev/fix-deserialization-bug-in-vtkCollection.md b/Documentation/release/dev/fix-deserialization-bug-in-vtkCollection.md new file mode 100644 index 00000000000..cf31e8427c4 --- /dev/null +++ b/Documentation/release/dev/fix-deserialization-bug-in-vtkCollection.md @@ -0,0 +1,6 @@ +# Fix deserialization bug in vtkCollection + +Fixes a bug in the deserialization of `vtkRenderer`. When an actor in a renderer was replaced with another actor, +and the scene reserialized with `vtkObjectManager`, the deserializer was unable to detect that the actor had +changed. Instead, the renderer continued to show the old actor. This bug in deserialization of vtkCollection +is now fixed. diff --git a/Wrapping/Tools/vtkWrapSerDesProperty.c b/Wrapping/Tools/vtkWrapSerDesProperty.c index 24b85a1cca3..2b215fc1cf8 100644 --- a/Wrapping/Tools/vtkWrapSerDesProperty.c +++ b/Wrapping/Tools/vtkWrapSerDesProperty.c @@ -561,22 +561,14 @@ int vtkWrapSerDes_WritePropertyDeserializer(FILE* fp, const ClassInfo* classInfo fprintf(fp, " if ((iter != state.end()) && !iter->is_null())\n"); fprintf(fp, " {\n"); fprintf(fp, " const auto items = iter->get();\n"); - fprintf(fp, - " const size_t numExistingItems = static_cast(object->GetNumberOf%ss());\n", - keyName); - fprintf(fp, " bool populateCollection = numExistingItems == 0;\n"); - fprintf(fp, " if (items.size() != numExistingItems)\n"); - fprintf(fp, " {\n"); - fprintf(fp, " object->RemoveAll%ss();\n", keyName); - fprintf(fp, " populateCollection = true;\n"); - fprintf(fp, " }\n"); + fprintf(fp, " object->RemoveAll%ss();\n", keyName); fprintf(fp, " const auto* context = deserializer->GetContext();\n"); fprintf(fp, " for (const auto& item: items)\n"); fprintf(fp, " {\n"); fprintf(fp, " const auto identifier = item.at(\"Id\").get();\n"); fprintf(fp, " auto subObject = context->GetObjectAtId(identifier);\n"); fprintf(fp, " deserializer->DeserializeJSON(identifier, subObject);\n"); - fprintf(fp, " if (populateCollection && subObject != nullptr)\n"); + fprintf(fp, " if (subObject != nullptr)\n"); fprintf(fp, " {\n"); fprintf(fp, " auto* itemAsObject = vtkObject::SafeDownCast(subObject);\n"); fprintf(fp, " object->Add%s(reinterpret_cast<%s*>(itemAsObject));\n", keyName,