From 5c6ab3d8c8028e5bd2be32cf3bc96ffbe9330829 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 7 Apr 2019 07:52:21 +0200 Subject: [PATCH] V1016 CWE-681 --- src/Mod/Sketcher/Gui/Command.cpp | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index 47f982a1ba..42327c8d88 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -206,7 +206,7 @@ void CmdSketcherNewSketch::activated(int iMsg) openCommand("Create a Sketch on Face"); doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); - if (mapmode >= 0 && mapmode < Attacher::mmDummy_NumberOfModes) + if (mapmode < Attacher::mmDummy_NumberOfModes) doCommand(Gui,"App.activeDocument().%s.MapMode = \"%s\"",FeatName.c_str(),AttachEngine::getModeName(mapmode).c_str()); else assert(0 /* mapmode index out of range */); @@ -324,14 +324,14 @@ void CmdSketcherLeaveSketch::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document *doc = getActiveGuiDocument(); - + if (doc) { // checks if a Sketch Viewprovider is in Edit and is in no special mode SketcherGui::ViewProviderSketch* vp = dynamic_cast(doc->getInEdit()); if (vp && vp->getSketchMode() != ViewProviderSketch::STATUS_NONE) vp->purgeHandler(); } - + openCommand("Sketch changed"); doCommand(Gui,"Gui.activeDocument().resetEdit()"); doCommand(Doc,"App.ActiveDocument.recompute()"); @@ -690,60 +690,60 @@ void CmdSketcherMirrorSketch::activated(int iMsg) qApp->translate("CmdSketcherMirrorSketch", "Select one or more sketches, please.")); return; } - + // Ask the user which kind of mirroring he wants SketchMirrorDialog * smd = new SketchMirrorDialog(); - + int refgeoid=-1; Sketcher::PointPos refposid=Sketcher::none; - + if( smd->exec() == QDialog::Accepted ){ refgeoid=smd->RefGeoid; refposid=smd->RefPosid; - + delete smd; } else { delete smd; return; } - + App::Document* doc = App::GetApplication().getActiveDocument(); - + openCommand("Create a mirror Sketch for each sketch"); - + for (std::vector::const_iterator it=selection.begin(); it != selection.end(); ++it) { - // create Sketch + // create Sketch std::string FeatName = getUniqueObjectName("MirroredSketch"); - + doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); - - Sketcher::SketchObject* mirrorsketch = static_cast(doc->getObject(FeatName.c_str())); - + + Sketcher::SketchObject* mirrorsketch = static_cast(doc->getObject(FeatName.c_str())); + const Sketcher::SketchObject* Obj = static_cast((*it).getObject()); - + Base::Placement pl = Obj->Placement.getValue(); - + Base::Vector3d p = pl.getPosition(); Base::Rotation r = pl.getRotation(); - + doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))", FeatName.c_str(), p.x,p.y,p.z,r[0],r[1],r[2],r[3]); - + Sketcher::SketchObject* tempsketch = new Sketcher::SketchObject(); - + int addedGeometries=tempsketch->addGeometry(Obj->getInternalGeometry()); - + int addedConstraints=tempsketch->addConstraints(Obj->Constraints.getValues()); std::vector geoIdList; - + for(int i=0;i<=addedGeometries;i++) geoIdList.push_back(i); - + tempsketch->addSymmetric(geoIdList, refgeoid, refposid); - + std::vector tempgeo = tempsketch->getInternalGeometry(); std::vector tempconstr = tempsketch->Constraints.getValues(); @@ -751,7 +751,7 @@ void CmdSketcherMirrorSketch::activated(int iMsg) std::vector mirrorconstr (tempconstr.begin()+addedConstraints+1,tempconstr.end()); for (std::vector::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) { - + if ((*itc)->First!=Sketcher::Constraint::GeoUndef || (*itc)->First==Sketcher::GeoEnum::HAxis || (*itc)->First==Sketcher::GeoEnum::VAxis) // not x, y axes or origin (*itc)->First-=(addedGeometries+1); if ((*itc)->Second!=Sketcher::Constraint::GeoUndef || (*itc)->Second==Sketcher::GeoEnum::HAxis || (*itc)->Second==Sketcher::GeoEnum::VAxis) // not x, y axes or origin @@ -759,15 +759,15 @@ void CmdSketcherMirrorSketch::activated(int iMsg) if ((*itc)->Third!=Sketcher::Constraint::GeoUndef || (*itc)->Third==Sketcher::GeoEnum::HAxis || (*itc)->Third==Sketcher::GeoEnum::VAxis) // not x, y axes or origin (*itc)->Third-=(addedGeometries+1); } - + mirrorsketch->addGeometry(mirrorgeo); mirrorsketch->addConstraints(mirrorconstr); - + delete tempsketch; } - + doCommand(Gui,"App.activeDocument().recompute()"); - + } bool CmdSketcherMirrorSketch::isActive(void) @@ -803,7 +803,7 @@ void CmdSketcherMergeSketches::activated(int iMsg) App::Document* doc = App::GetApplication().getActiveDocument(); - // create Sketch + // create Sketch std::string FeatName = getUniqueObjectName("Sketch"); openCommand("Create a merge Sketch");