From b833f59bb5b25897f85b44c0f3f4fbc3ddeceb62 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sun, 10 Aug 2014 10:17:01 +0200 Subject: [PATCH] Show at least one row per page In theory a font could be so large that no full row would fit on the allotted space; in that case showing a partial row is better than nothing and will avoid bugs where -1 wraps around on unsigned exprs. --- src/textdialog.cpp | 2 +- src/textmanualdialog.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textdialog.cpp b/src/textdialog.cpp index 8ca2e3b..5c317af 100644 --- a/src/textdialog.cpp +++ b/src/textdialog.cpp @@ -80,7 +80,7 @@ void TextDialog::exec() { const int fontHeight = gmenu2x->font->getLineSpacing(); unsigned int contentY, contentHeight; tie(contentY, contentHeight) = gmenu2x->getContentArea(); - const unsigned rowsPerPage = contentHeight / fontHeight; + const unsigned rowsPerPage = max(contentHeight / fontHeight, 1u); const unsigned maxFirstRow = text.size() < rowsPerPage ? 0 : text.size() - rowsPerPage; contentY += (contentHeight % fontHeight) / 2; diff --git a/src/textmanualdialog.cpp b/src/textmanualdialog.cpp index 0632c0c..1b17a6c 100644 --- a/src/textmanualdialog.cpp +++ b/src/textmanualdialog.cpp @@ -92,7 +92,7 @@ void TextManualDialog::exec() { ss >> spagecount; string pageStatus; - const unsigned rowsPerPage = 180 / gmenu2x->font->getLineSpacing(); + const unsigned rowsPerPage = max(180u / gmenu2x->font->getLineSpacing(), 1u); unsigned page = 0, firstRow = 0; bool close = false;