+ fixes #0001808: Double Clicking Sketcher PolyLine Causing Crash
This commit is contained in:
parent
efe414e4c2
commit
d30eb39a1e
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <boost/math/special_functions/fpclassify.hpp>
|
#include <boost/math/special_functions/fpclassify.hpp>
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/Exception.h>
|
||||||
|
|
||||||
#include <Gui/Action.h>
|
#include <Gui/Action.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
@ -802,6 +803,7 @@ public:
|
||||||
resetPositionText();
|
resetPositionText();
|
||||||
sketchgui->drawEdit(EditCurve);
|
sketchgui->drawEdit(EditCurve);
|
||||||
sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider
|
sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider
|
||||||
|
return true; // 'this' instance is destroyed now!
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode = STATUS_Do;
|
Mode = STATUS_Do;
|
||||||
|
@ -824,15 +826,22 @@ public:
|
||||||
virtual bool releaseButton(Base::Vector2D onSketchPos)
|
virtual bool releaseButton(Base::Vector2D onSketchPos)
|
||||||
{
|
{
|
||||||
if (Mode == STATUS_Do || Mode == STATUS_Close) {
|
if (Mode == STATUS_Do || Mode == STATUS_Close) {
|
||||||
|
bool addedGeometry = true;
|
||||||
if (SegmentMode == SEGMENT_MODE_Line) {
|
if (SegmentMode == SEGMENT_MODE_Line) {
|
||||||
// open the transaction
|
// open the transaction
|
||||||
Gui::Command::openCommand("Add line to sketch wire");
|
Gui::Command::openCommand("Add line to sketch wire");
|
||||||
// issue the geometry
|
// issue the geometry
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,
|
try {
|
||||||
"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
Gui::Command::doCommand(Gui::Command::Doc,
|
||||||
sketchgui->getObject()->getNameInDocument(),
|
"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||||
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY);
|
sketchgui->getObject()->getNameInDocument(),
|
||||||
|
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY);
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
addedGeometry = false;
|
||||||
|
Base::Console().Error("Failed to add line: %s\n", e.what());
|
||||||
|
Gui::Command::abortCommand();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (SegmentMode == SEGMENT_MODE_Arc) { // We're dealing with an Arc
|
else if (SegmentMode == SEGMENT_MODE_Arc) { // We're dealing with an Arc
|
||||||
if (!boost::math::isnormal(arcRadius)) {
|
if (!boost::math::isnormal(arcRadius)) {
|
||||||
|
@ -840,15 +849,22 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Gui::Command::openCommand("Add arc to sketch wire");
|
Gui::Command::openCommand("Add arc to sketch wire");
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,
|
try {
|
||||||
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
|
Gui::Command::doCommand(Gui::Command::Doc,
|
||||||
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))",
|
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
|
||||||
sketchgui->getObject()->getNameInDocument(),
|
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))",
|
||||||
CenterPoint.fX, CenterPoint.fY, std::abs(arcRadius),
|
sketchgui->getObject()->getNameInDocument(),
|
||||||
std::min(startAngle,endAngle), std::max(startAngle,endAngle));
|
CenterPoint.fX, CenterPoint.fY, std::abs(arcRadius),
|
||||||
|
std::min(startAngle,endAngle), std::max(startAngle,endAngle));
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
addedGeometry = false;
|
||||||
|
Base::Console().Error("Failed to add arc: %s\n", e.what());
|
||||||
|
Gui::Command::abortCommand();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// issue the constraint
|
// issue the constraint
|
||||||
if (previousPosId != Sketcher::none) {
|
if (addedGeometry && (previousPosId != Sketcher::none)) {
|
||||||
int lastCurve = getHighestCurveIndex();
|
int lastCurve = getHighestCurveIndex();
|
||||||
Sketcher::PointPos lastStartPosId = (SegmentMode == SEGMENT_MODE_Arc && startAngle > endAngle) ?
|
Sketcher::PointPos lastStartPosId = (SegmentMode == SEGMENT_MODE_Arc && startAngle > endAngle) ?
|
||||||
Sketcher::end : Sketcher::start;
|
Sketcher::end : Sketcher::start;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user