Commit 6f31b063 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Avoid division by zero in the basic smoothing algorithm

This causes bended lines when the events are coming not-gradually.
parent 18182260
......@@ -350,11 +350,11 @@ void KisToolFreehandHelper::paint(KoPointerEvent *event)
if (!m_d->haveTangent) {
m_d->haveTangent = true;
m_d->previousTangent =
(info.pos() - m_d->previousPaintInformation.pos()) /
(info.currentTime() - m_d->previousPaintInformation.currentTime());
(info.pos() - m_d->previousPaintInformation.pos()) /
qMax(1, info.currentTime() - m_d->previousPaintInformation.currentTime());
} else {
QPointF newTangent = (info.pos() - m_d->olderPaintInformation.pos()) /
(info.currentTime() - m_d->olderPaintInformation.currentTime());
qMax(1, info.currentTime() - m_d->olderPaintInformation.currentTime());
paintBezierSegment(m_d->olderPaintInformation, m_d->previousPaintInformation,
m_d->previousTangent, newTangent);
......
Markdown is supported
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