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:
Eskil Abrahamsen Blomfeldt 2014-09-11 10:01:44 +02:00 committed by Eskil Abrahamsen Blomfeldt
parent 4b6d873725
commit c1b46b98ed
1 changed files with 2 additions and 1 deletions

View File

@ -998,7 +998,8 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
} else {
vmax = qMax(0, doc->lineCount() - 1);
vSliderLength = viewport->height() / q->fontMetrics().lineSpacing();
int lineSpacing = q->fontMetrics().lineSpacing();
vSliderLength = lineSpacing != 0 ? viewport->height() / lineSpacing : 0;
}