Qt: Make sure the packet diagram's FT_NONE label exists.

Gap items have a null field_info pointer, so set "Unknown" as the
default representation string and fill it in after we've established
that field_info is valid. Closes #16851.
This commit is contained in:
Gerald Combs 2020-09-15 11:55:15 -07:00 committed by Wireshark GitLab Utility
parent 0c373d648a
commit 3426b25621
1 changed files with 8 additions and 7 deletions

View File

@ -95,7 +95,7 @@ public:
FieldInformationGraphicsItem(field_info *fi, int start_bit, int fi_length, const DiagramLayout *layout, QGraphicsItem *parent = nullptr) :
QGraphicsPolygonItem(QPolygonF(), parent),
finfo_(new FieldInformation(fi)),
representation(fi->rep->representation),
representation_("Unknown"),
start_bit_(start_bit),
layout_(layout),
collapsed_len_(fi_length),
@ -173,6 +173,7 @@ public:
.arg(finfo_->headerInfo().abbreviation)
.arg(finfo_->toString()));
setData(Qt::UserRole, VariantPointer<field_info>::asQVariant(finfo_->fieldInfo()));
representation_ = fi->rep->representation;
} else {
setToolTip(QObject::tr("Gap in dissection"));
}
@ -242,11 +243,11 @@ public:
// Field label(s)
QString label;
if (finfo_->headerInfo().type == FT_NONE) {
label = representation;
} else {
label = finfo_->headerInfo().name;
}
if (finfo_->headerInfo().type == FT_NONE) {
label = representation_;
} else {
label = finfo_->headerInfo().name;
}
paintLabel(painter, label, scaled_tr_);
if (layout_->showFields()) {
@ -264,7 +265,7 @@ private:
NumSpanMarks
};
FieldInformation *finfo_;
QString representation;
QString representation_;
int start_bit_;
const DiagramLayout *layout_;
int collapsed_len_;