Commit 9efeb767 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix a hangup+crash in the line tool when the line is too short

The fix might be related to the bug below, though I'm not very sure

CCBUG:460461

# Conflicts:
#	plugins/tools/basictools/kis_tool_line_helper.cpp
parent 0641f768
Pipeline #256889 failed with stage
in 75 minutes and 1 second
......@@ -132,20 +132,25 @@ void KisToolLineHelper::addPoint(KoPointerEvent *event, const QPointF &overrideP
if (m_d->linePoints.size() > 1) {
const QPointF startPos = m_d->linePoints.first().pos();
const QPointF endPos = pi.pos();
const qreal maxDistance = kisDistance(startPos, endPos);
const QPointF unit = (endPos - startPos) / maxDistance;
QVector<KisPaintInformation>::iterator it = m_d->linePoints.begin();
++it;
while (it != m_d->linePoints.end()) {
qreal dist = kisDistance(startPos, it->pos());
if (dist < maxDistance) {
QPointF pos = startPos + unit * dist;
it->setPos(pos);
++it;
} else {
it = m_d->linePoints.erase(it);
if (!KisAlgebra2D::fuzzyPointCompare(startPos, endPos)) {
const qreal maxDistance = kisDistance(startPos, endPos);
const QPointF unit = (endPos - startPos) / maxDistance;
QVector<KisPaintInformation>::iterator it = m_d->linePoints.begin();
++it;
while (it != m_d->linePoints.end()) {
qreal dist = kisDistance(startPos, it->pos());
if (dist < maxDistance) {
QPointF pos = startPos + unit * dist;
it->setPos(pos);
++it;
} else {
it = m_d->linePoints.erase(it);
}
}
} else {
m_d->linePoints.clear();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment