aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaf <naf@sdf.org>2021-02-02 13:25:52 -0600
committerPascal Quantin <pascal@wireshark.org>2021-04-19 20:08:17 +0200
commiteee907aeb5e6d7548d413d69fd1122411a05390f (patch)
tree1ccb08b5d0e5c68aef11bf164d153d77674574cd
parentcc954fae7e56f1c46fb4424aff84e9a7f3aca64f (diff)
QT ByteViewText: calculate string widths consistently to prevent clipping
For QT >5.11, stringWidth() uses horizontalAdvance, which gives different (longer) widths than the old boundingRect().width() method. Other locations use the boundRect().width() method directly, resulting in underestimating line widths and clipping the last characters in the byte view window. Fix by forcing all width calculations to use stringWidth(). Closes #17087. (cherry picked from commit 95f3d1b0750044967c6cf2f767d809453ca7819b) Conflicts: ui/qt/widgets/byte_view_text.cpp
-rw-r--r--ui/qt/widgets/byte_view_text.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp
index abf292c50d..a89876ab8e 100644
--- a/ui/qt/widgets/byte_view_text.cpp
+++ b/ui/qt/widgets/byte_view_text.cpp
@@ -607,7 +607,7 @@ int ByteViewText::offsetPixels()
if (show_offset_) {
// One pad space before and after
QString zeroes = QString(offsetChars(), '0');
- return fontMetrics().boundingRect(zeroes).width();
+ return stringWidth(zeroes);
}
return 0;
}
@@ -618,7 +618,7 @@ int ByteViewText::hexPixels()
if (show_hex_) {
// One pad space before and after
QString zeroes = QString(DataPrinter::hexChars() + 2, '0');
- return fontMetrics().boundingRect(zeroes).width();
+ return stringWidth(zeroes);
}
return 0;
}
@@ -629,7 +629,7 @@ int ByteViewText::asciiPixels()
// Two pad spaces before, one after
int ascii_chars = (row_width_ + ((row_width_ - 1) / separator_interval_));
QString zeroes = QString(ascii_chars + 3, '0');
- return fontMetrics().boundingRect(zeroes).width();
+ return stringWidth(zeroes);
}
return 0;
}