Commit 9b0430fc authored by Halla Rempt's avatar Halla Rempt

Be careful: QColor::fromHslF can sometimes return an invalid qcolor

Which causes asserts.

QColor::fromHsvF: HSV parameters out of range
Could not construct valid color from h 0.833333 s 1 l -8.63674e-28 a 1
parent 2900f7be
......@@ -494,8 +494,7 @@ QImage KisDisplayColorConverter::toQImage(KisPaintDeviceSP srcDevice) const
return QImage();
KisDisplayColorConverter::Private::approximateFromQColor(const QColor &qcolor)
KoColor KisDisplayColorConverter::Private::approximateFromQColor(const QColor &qcolor)
if (!useOcio()) {
return KoColor(qcolor, paintingColorSpace);
......@@ -555,7 +554,12 @@ KoColor KisDisplayColorConverter::fromHslF(qreal h, qreal s, qreal l, qreal a)
// generate HSL from sRGB!
QColor qcolor(QColor::fromHslF(h, s, l, a));
if (!qcolor.isValid()) {
qWarning() << "Could not construct valid color from h" << h << "s" << s << "l" << l << "a" << a;
qcolor = Qt::black;
return m_d->approximateFromQColor(qcolor);
void KisDisplayColorConverter::getHslF(const KoColor &srcColor, qreal *h, qreal *s, qreal *l, qreal *a)
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