fix(jointsservice): clear children after initializing

This commit is contained in:
maelstrom 2025-04-23 19:53:44 +02:00
parent 6799b93a06
commit c26c9aaeef
2 changed files with 7 additions and 1 deletions

View file

@ -1,5 +1,6 @@
#include "jointsservice.h"
#include "workspace.h"
#include <memory>
const InstanceType JointsService::TYPE = {
.super = &Instance::TYPE,
@ -21,6 +22,11 @@ JointsService::~JointsService() = default;
void JointsService::InitService() {
if (initialized) return;
initialized = true;
// Clear children before any new joints are added
for (std::shared_ptr<Instance> inst : dataModel().value()->GetService<JointsService>()->GetChildren()) {
inst->Destroy();
}
}
std::optional<std::shared_ptr<Workspace>> JointsService::jointWorkspace() {

View file

@ -177,7 +177,7 @@ MainWindow::MainWindow(QWidget *parent)
snap->c1 = part0->cframe;
// gWorkspace()->AddChild(snap);
gDataModel->GetService<JointsService>()->AddChild(snap);
gWorkspace()->AddChild(snap);
snap->UpdateProperty("Part0");
snap->UpdateProperty("Part1");
}