PathAction *ModelUavoProxy::createPathAction(int index, PathAction *newAction) { PathAction *action = NULL; int count = objMngr->getNumInstances(PathAction::OBJID); if (index < count) { // reuse object qDebug() << "ModelUAVProxy::createPathAction - reused action instance :" << index << "/" << count; action = PathAction::GetInstance(objMngr, index); if (newAction) { newAction->deleteLater(); } } else if (index < count + 1) { // create "next" object qDebug() << "ModelUAVProxy::createPathAction - created action instance :" << index; // TODO is there a limit to the number of path actions? action = newAction ? newAction : new PathAction; action->initialize(index, action->getMetaObject()); objMngr->registerObject(action); } else { // we can only create the "next" object // TODO fail in a clean way :( } return action; }