fix FreeCad crash when no tool is assigned to an operation

This commit is contained in:
Shai Seger
2018-05-07 18:54:19 +03:00
committed by Yorik van Havre
parent ec072982f7
commit b2e9348892
2 changed files with 28 additions and 17 deletions

View File

@@ -480,22 +480,30 @@ class PathSimulation:
self.cutTool.ViewObject.hide()
self.iprogress = 0
self.EndSimulation()
def InvalidOperation(self):
if len(self.activeOps) == 0:
return True
if (self.tool == None):
TSError("No tool assigned for the operation")
return True
return false
def SimFF(self):
if len(self.activeOps) == 0:
if self.InvalidOperation():
return
self.GuiBusy(True)
self.timer.start(1)
self.disableAnim = True
def SimStep(self):
if len(self.activeOps) == 0:
if self.InvalidOperation():
return
self.disableAnim = False
self.PerformCut()
def SimPlay(self):
if len(self.activeOps) == 0:
if self.InvalidOperation():
return
self.disableAnim = False
self.GuiBusy(True)

View File

@@ -125,21 +125,24 @@ Base::Placement * PathSim::ApplyCommand(Base::Placement * pos, Command * cmd)
Point3D fromPos(*pos);
Point3D toPos(*pos);
toPos.UpdateCmd(*cmd);
if (cmd->Name == "G0" || cmd->Name == "G1")
if (m_tool != NULL)
{
m_stock->ApplyLinearTool(fromPos, toPos, *m_tool);
}
else if (cmd->Name == "G2")
{
Vector3d vcent = cmd->getCenter();
Point3D cent(vcent);
m_stock->ApplyCircularTool(fromPos, toPos, cent, *m_tool, false);
}
else if (cmd->Name == "G3")
{
Vector3d vcent = cmd->getCenter();
Point3D cent(vcent);
m_stock->ApplyCircularTool(fromPos, toPos, cent, *m_tool, true);
if (cmd->Name == "G0" || cmd->Name == "G1")
{
m_stock->ApplyLinearTool(fromPos, toPos, *m_tool);
}
else if (cmd->Name == "G2")
{
Vector3d vcent = cmd->getCenter();
Point3D cent(vcent);
m_stock->ApplyCircularTool(fromPos, toPos, cent, *m_tool, false);
}
else if (cmd->Name == "G3")
{
Vector3d vcent = cmd->getCenter();
Point3D cent(vcent);
m_stock->ApplyCircularTool(fromPos, toPos, cent, *m_tool, true);
}
}
Base::Placement *plc = new Base::Placement();