Re: [Bug] rs_actiondrawellipsecenter3point
Posted by dxli on Jun 05, 2013; 1:53am
URL: https://forum.librecad.org/Bug-rs-actiondrawellipsecenter3point-tp5708194p5708209.html
Hi,
It's a mistake in line 383 of lc_quadratic.cpp RS_VectorSolutions LC_Quadratic::getIntersection(const LC_Quadratic& l1, const LC_Quadratic& l2);
We only go ahead to find intersections when both quadratic forms are valid.
I pushed the fix to master branch, commit: fb5712b
The steps to reproduce the crash:
0, enable snap to grid only.
1, start draw ellipse by center and 3 points;
2, choose any center;
3, choose another point at one grid point as the first point;
4, when proposed to choose the second point, move to the same grid point chosen in step 3.
Results: LibreCAD crashes.
a patch to fix it:
diff --git a/librecad/src/lib/math/lc_quadratic.cpp b/librecad/src/lib/math/lc_quadratic.cpp
index 7c5712b..1dcf78a 100644
--- a/librecad/src/lib/math/lc_quadratic.cpp
+++ b/librecad/src/lib/math/lc_quadratic.cpp
@@ -380,7 +380,7 @@ LC_Quadratic LC_Quadratic::flipXY(void) const
RS_VectorSolutions LC_Quadratic::getIntersection(const LC_Quadratic& l1, const LC_Quadratic& l2)
{
RS_VectorSolutions ret;
- if( (l1.isValid() && l2.isValid()) == false ) {
+ if( (l1.isValid()==false && l2.isValid()) == false ) {
// DEBUG_HEADER();
// std::cout<<l1<<std::endl;
// std::cout<<l2<<std::endl;