Commit fac1d60b 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
parent 92b3dc56
Pipeline #255913 passed with stage
in 66 minutes and 39 seconds
......@@ -137,20 +137,25 @@ void KisToolLineHelper::addPoint(KisPaintInformation pi, const QPointF &override
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();
}
}
......@@ -175,6 +180,10 @@ void KisToolLineHelper::movePointsTo(const QPointF &startPoint, const QPointF &e
return;
}
if (KisAlgebra2D::fuzzyPointCompare(startPoint, endPoint)) {
return;
}
if (m_d->linePoints.size() > 1) {
const qreal maxDistance = kisDistance(startPoint, endPoint);
const QPointF unit = (endPoint - startPoint) / maxDistance;
......
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