------------------------------------------------------------------------------
| 714 | |
| 715 | //------------------------------------------------------------------------------ |
| 716 | void vtkObjectManager::UpdateStatesFromObjects() |
| 717 | { |
| 718 | // Reset dependency cache as it will be rebuilt. |
| 719 | this->Context->ResetDirectDependencies(); |
| 720 | // All objects go under the top level root node |
| 721 | vtkMarshalContext::ScopedParentTracker rootNodeTracker(this->Context, vtkObjectManager::ROOT()); |
| 722 | // serializes all objects with strong references held by the manager. |
| 723 | const auto managerStrongObjectsIter = this->Context->StrongObjects().find(this->OWNERSHIP_KEY()); |
| 724 | // serializes all objects with strong references held by the deserializer. |
| 725 | const auto deserializerOwnershipKey = this->Deserializer->GetObjectDescription(); |
| 726 | const auto deserStrongObjectsIter = this->Context->StrongObjects().find(deserializerOwnershipKey); |
| 727 | // serializes all objects with strong references held by the invoker. |
| 728 | const auto invokerOwnershipKey = this->Invoker->GetObjectDescription(); |
| 729 | const auto invokerStrongObjectsIter = this->Context->StrongObjects().find(invokerOwnershipKey); |
| 730 | if (managerStrongObjectsIter != this->Context->StrongObjects().end()) |
| 731 | { |
| 732 | for (const auto& object : managerStrongObjectsIter->second) |
| 733 | { |
| 734 | auto stateId = this->Serializer->SerializeJSON(object); |
| 735 | auto idIter = stateId.find("Id"); |
| 736 | if ((idIter != stateId.end()) && idIter->is_number_unsigned()) |
| 737 | { |
| 738 | auto& state = this->Context->GetState(idIter->get<vtkTypeUInt32>()); |
| 739 | state["vtk-object-manager-kept-alive"] = true; |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | if (deserStrongObjectsIter != this->Context->StrongObjects().end()) |
| 744 | { |
| 745 | for (const auto& object : deserStrongObjectsIter->second) |
| 746 | { |
| 747 | this->Serializer->SerializeJSON(object); |
| 748 | } |
| 749 | } |
| 750 | if (invokerStrongObjectsIter != this->Context->StrongObjects().end()) |
| 751 | { |
| 752 | for (const auto& object : invokerStrongObjectsIter->second) |
| 753 | { |
| 754 | this->Serializer->SerializeJSON(object); |
| 755 | } |
| 756 | } |
| 757 | // Remove unused states |
| 758 | this->PruneUnusedStates(); |
| 759 | // Remove unused objects |
| 760 | this->PruneUnusedObjects(); |
| 761 | } |
| 762 | |
| 763 | //------------------------------------------------------------------------------ |
| 764 | void vtkObjectManager::UpdateStatesFromObjects(const std::vector<vtkTypeUInt32>& identifiers) |