OpenToonz - An open-source full-featured 2D animation creation software
C
Fix crashes in GeometricTool with MyPaint brush single/double click
Anderson Prado0b2740a1a99a
diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cppindex 28e8b2da5..5305c4aae 100644--- a/toonz/sources/tnztools/geometrictool.cpp+++ b/toonz/sources/tnztools/geometrictool.cpp@@ -1581,7 +1581,7 @@ void GeometricTool::addStroke() {TStroke *stroke = 0;if (!m_isRotatingOrMoving) {stroke = m_primitive->makeStroke();- if (!stroke) return;+ if (!stroke) return; // Exit if stroke is nullif (m_param.m_rotate.getValue()) {m_isRotatingOrMoving = true;@@ -1615,6 +1615,8 @@ void GeometricTool::addStroke() {m_rotatedStroke = 0;}+ if (!stroke) return; // Add null check here+TStroke::OutlineOptions &options = stroke->outlineOptions();options.m_capStyle = m_param.m_capStyle.getIndex();options.m_joinStyle = m_param.m_joinStyle.getIndex();@@ -2623,8 +2625,15 @@ void LinePrimitive::leftButtonUp(const TPointD &pos, const TMouseEvent &e) {elsem_vertex.push_back(newPos);- endLine();+ // Check if vertices are valid and distinct before calling endLine+ if (m_vertex.size() < 2 || m_vertex[0] == m_vertex[1]) {+ m_vertex.clear();+ m_isEditing = false;+ resetSnap();+ return;+ }+ endLine();resetSnap();}//-----------------------------------------------------------------------------