Fix divide by zero when opening font on invalid image
If you open a QFont on an invalid image, its dpi will be 0. In other places we check for this before calculating the point size, but this was missing in one spot, causing divide by zero. This would happen e.g. in the tst_QFontMetrics::same() test. While it would pass normally, running this with an undefined sanitizer build would warn about the division by zero. There's nothing useful we can do with the fonts on the invalid image, so like in the other places, we just leave the point size as is when this happens. Pick-to: 5.15 6.5 6.8 6.9 Change-Id: I4769e23e2b4dbb92f675cb8a77f8554c90bc2afd Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
parent
83a4128ecb
commit
c136de2deb
@ -2828,7 +2828,8 @@ void QFontDatabasePrivate::load(const QFontPrivate *d, int script)
|
||||
req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
|
||||
req.pixelSize = qRound(req.pixelSize);
|
||||
}
|
||||
if (req.pointSize < 0)
|
||||
|
||||
if (req.pointSize < 0 && d->dpi > 0)
|
||||
req.pointSize = req.pixelSize*72.0/d->dpi;
|
||||
|
||||
// respect the fallback families that might be passed through the request
|
||||
|
Loading…
x
Reference in New Issue
Block a user