mirror of https://github.com/qt/qtbase.git
Avoid divide-by-zero in the gradients example
After 7a738daa97
we require
QLineF::setLength() to take a finite length, and this code was probably
always risky when HoverPoints has two points that are both 0,0.
It's probably a transient condition anyway.
Fixes: QTBUG-92908
Change-Id: If81122d2f78761026b0d656ceffe173132751317
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
8f429ac926
commit
76537c065a
|
@ -105,6 +105,8 @@ uint ShadeWidget::colorAt(int x)
|
|||
for (int i = 1; i < pts.size(); ++i) {
|
||||
if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) {
|
||||
QLineF l(pts.at(i - 1), pts.at(i));
|
||||
if (qIsNull(l.dx()))
|
||||
continue;
|
||||
l.setLength(l.length() * ((x - l.x1()) / l.dx()));
|
||||
return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))),
|
||||
qRound(qMin(l.y2(), qreal(m_shade.height() - 1))));
|
||||
|
|
Loading…
Reference in New Issue