mirror of https://github.com/qt/qtbase.git
Fix possible divide by zero in QPlainTextEdit
If the font engine for some reason fails to get font metrics for the font, the application should still not crash. [ChangeLog][Widgets][QPlainTextEdit] Fixed a possible divide by zero crash when font metrics were missing for the font. Task-number: QTBUG-40347 Change-Id: I571bc3eace07cdbee6f9ce9aa649df95412aed71 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
4b6d873725
commit
c1b46b98ed
|
@ -998,7 +998,8 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vmax = qMax(0, doc->lineCount() - 1);
|
vmax = qMax(0, doc->lineCount() - 1);
|
||||||
vSliderLength = viewport->height() / q->fontMetrics().lineSpacing();
|
int lineSpacing = q->fontMetrics().lineSpacing();
|
||||||
|
vSliderLength = lineSpacing != 0 ? viewport->height() / lineSpacing : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue