------------------------------------------------------------------------------
| 684 | |
| 685 | //------------------------------------------------------------------------------ |
| 686 | void vtkObjectManager::UpdateObjectsFromStates() |
| 687 | { |
| 688 | // Reset dependency cache as it will be rebuilt. |
| 689 | this->Context->ResetDirectDependencies(); |
| 690 | // All objects go under the top level root node |
| 691 | vtkMarshalContext::ScopedParentTracker rootNodeTracker(this->Context, vtkObjectManager::ROOT()); |
| 692 | // only deserialize those objects which are strong references |
| 693 | nlohmann::json strongRefStates; |
| 694 | const auto& states = this->Context->States(); |
| 695 | std::copy_if(states.begin(), states.end(), std::back_inserter(strongRefStates), |
| 696 | [](const nlohmann::json& item) |
| 697 | { |
| 698 | return item.contains("vtk-object-manager-kept-alive") && |
| 699 | item["vtk-object-manager-kept-alive"] == true; |
| 700 | }); |
| 701 | const auto deserializerOwnershipKey = this->Deserializer->GetObjectDescription(); |
| 702 | for (const auto& state : strongRefStates) |
| 703 | { |
| 704 | const auto identifier = state.at("Id").get<vtkTypeUInt32>(); |
| 705 | auto object = this->Context->GetObjectAtId(identifier); |
| 706 | this->Deserializer->DeserializeJSON(identifier, object); |
| 707 | this->Context->KeepAlive(deserializerOwnershipKey, object); |
| 708 | } |
| 709 | // Remove unused objects |
| 710 | this->PruneUnusedObjects(); |
| 711 | // Remove unused states |
| 712 | this->PruneUnusedStates(); |
| 713 | } |
| 714 | |
| 715 | //------------------------------------------------------------------------------ |
| 716 | void vtkObjectManager::UpdateStatesFromObjects() |