From 9c88c3fe4c88539c6772045c4f6400312ad61fc6 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 18 Apr 2023 18:19:51 +0200 Subject: [PATCH] cabana: fix displaying zero length messages (#27953) --- tools/cabana/util.cc | 6 +++--- tools/cabana/util.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/cabana/util.cc b/tools/cabana/util.cc index 4fe04a5160..74edc8a1d2 100644 --- a/tools/cabana/util.cc +++ b/tools/cabana/util.cc @@ -65,9 +65,9 @@ QSize MessageBytesDelegate::sizeHint(const QStyleOptionViewItem &option, const Q return {1, byte_size.height() + 2 * v_margin}; } int n = data.toByteArray().size(); - assert(n > 0 && n <= 64); + assert(n >= 0 && n <= 64); - QSize size = size_cache[n - 1]; + QSize size = size_cache[n]; if (size.isEmpty()) { if (!multiple_lines) { size.setWidth(widthForBytes(n)); @@ -76,7 +76,7 @@ QSize MessageBytesDelegate::sizeHint(const QStyleOptionViewItem &option, const Q size.setWidth(widthForBytes(8)); size.setHeight(byte_size.height() * std::max(1, n / 8) + 2 * v_margin); } - size_cache[n - 1] = size; + size_cache[n] = size; } return size; } diff --git a/tools/cabana/util.h b/tools/cabana/util.h index cd18b77448..5a3d129a76 100644 --- a/tools/cabana/util.h +++ b/tools/cabana/util.h @@ -76,7 +76,7 @@ private: QFont fixed_font; QSize byte_size = {}; bool multiple_lines = false; - mutable QSize size_cache[64] = {}; + mutable QSize size_cache[65] = {}; }; inline QString toHex(const QByteArray &dat) { return dat.toHex(' ').toUpper(); }