Skip to content

Commit

Permalink
Fix polyline buffer not always being cleared (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
scribblemaniac authored Apr 17, 2024
1 parent 06a4495 commit 2420280
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions core_lib/src/tool/polylinetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ bool PolylineTool::leavingThisTool()
if (mPoints.size() > 0)
{
cancelPolyline();
clearToolData();
}
return true;
}
Expand All @@ -117,8 +116,16 @@ QCursor PolylineTool::cursor()

void PolylineTool::clearToolData()
{
if (mPoints.empty()) {
return;
}

mPoints.clear();
emit isActiveChanged(POLYLINE, false);

// Clear the in-progress polyline from the bitmap buffer.
mScribbleArea->clearDrawingBuffer();
mScribbleArea->updateFrame();
}

void PolylineTool::pointerPressEvent(PointerEvent* event)
Expand Down Expand Up @@ -189,7 +196,6 @@ void PolylineTool::pointerDoubleClickEvent(PointerEvent* event)
mEditor->backup(typeName());

endPolyline(mPoints);
clearToolData();
}


Expand All @@ -201,7 +207,6 @@ bool PolylineTool::keyPressEvent(QKeyEvent* event)
if (mPoints.size() > 0)
{
endPolyline(mPoints);
clearToolData();
return true;
}
break;
Expand All @@ -210,7 +215,6 @@ bool PolylineTool::keyPressEvent(QKeyEvent* event)
if (mPoints.size() > 0)
{
cancelPolyline();
clearToolData();
return true;
}
break;
Expand Down Expand Up @@ -269,9 +273,7 @@ void PolylineTool::drawPolyline(QList<QPointF> points, QPointF endPoint)

void PolylineTool::cancelPolyline()
{
// Clear the in-progress polyline from the bitmap buffer.
mScribbleArea->clearDrawingBuffer();
mScribbleArea->updateFrame();
clearToolData();
}

void PolylineTool::endPolyline(QList<QPointF> points)
Expand Down Expand Up @@ -303,4 +305,6 @@ void PolylineTool::endPolyline(QList<QPointF> points)
}
mScribbleArea->endStroke();
mEditor->setModified(mEditor->layers()->currentLayerIndex(), mEditor->currentFrame());

clearToolData();
}

0 comments on commit 2420280

Please sign in to comment.