- SessionPtr aMgr = ModelAPI_Session::get();
-
- QString aName = tr("Detach %1").arg(aLine->data()->name().c_str());
- aMgr->startOperation(aName.toStdString());
+ ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(
+ tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
+ XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
+ // the active nested sketch operation should be aborted unconditionally
+ // the Delete action should be additionally granted for the Sketch operation
+ // in order to do not abort/commit it
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/))
+ return; // the objects are processed but can not be deleted
+
+ anOpMgr->startOperation(anOpAction);