refactor: replace raw object pointers with SmartPointer in ObjectsContext and update dependent codebases

This commit is contained in:
AndreaRigoni
2026-04-17 13:28:24 +00:00
parent 506b8f037f
commit 390fc44043
8 changed files with 57 additions and 41 deletions

View File

@@ -49,8 +49,8 @@ void ObjectsContext::Synchronize() {
// 1. Identify objects to add and remove
const auto &objects = m_Context->GetObjects();
std::map<uLib::Object *, bool> currentObjects;
for (auto obj : objects)
currentObjects[obj] = true;
for (const auto& obj : objects)
currentObjects[obj.get()] = true;
// Remove Prop3Ds for objects no longer in context
for (auto it = m_Prop3Ds.begin(); it != m_Prop3Ds.end();) {
@@ -71,11 +71,11 @@ void ObjectsContext::Synchronize() {
}
// Add Prop3Ds for new objects
for (auto obj : objects) {
if (m_Prop3Ds.find(obj) == m_Prop3Ds.end()) {
Prop3D *prop3d = this->CreateProp3D(obj);
for (const auto& obj : objects) {
if (m_Prop3Ds.find(obj.get()) == m_Prop3Ds.end()) {
Prop3D *prop3d = this->CreateProp3D(obj.get());
if (prop3d) {
m_Prop3Ds[obj] = prop3d;
m_Prop3Ds[obj.get()] = prop3d;
if (auto *p3d = vtkProp3D::SafeDownCast(prop3d->GetProp()))
m_Assembly->AddPart(p3d);
this->Prop3DAdded(prop3d);