forked from osmocom/wireshark
PacketListRecord: add an ensureColorized() method and use it.
Don't call the columnString() and discard the result in order to force
colorization; instead, add a separate method to force colorization and
use that.
This avoids the need to choose a column; we were using 1 as the column
number, but column numbers are zero-origin, so that's column 2, which
isn't guaranteed to exist (a crash ensued if it didn't).
(cherry picked from commit 58aea1de62
)
This commit is contained in:
parent
793142cbec
commit
899899533c
|
@ -760,7 +760,7 @@ void PacketListModel::ensureRowColorized(int row)
|
|||
if (!record)
|
||||
return;
|
||||
if (!record->colorized()) {
|
||||
record->columnString(cap_file_, 1, true);
|
||||
record->ensureColorized(cap_file_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,26 @@ PacketListRecord::~PacketListRecord()
|
|||
col_text_.clear();
|
||||
}
|
||||
|
||||
void PacketListRecord::ensureColorized(capture_file *cap_file)
|
||||
{
|
||||
// packet_list_store.c:packet_list_get_value
|
||||
Q_ASSERT(fdata_);
|
||||
|
||||
if (!cap_file) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// XXX - do we need to check whether the data versions match?
|
||||
// If the record's color is already correct, we shouldn't need
|
||||
// to redissect it to colorize it.
|
||||
//
|
||||
bool dissect_color = !colorized_ || ( color_ver_ != rows_color_ver_ );
|
||||
if (data_ver_ != col_data_ver_ || dissect_color) {
|
||||
dissect(cap_file, dissect_color);
|
||||
}
|
||||
}
|
||||
|
||||
// We might want to return a const char * instead. This would keep us from
|
||||
// creating excessive QByteArrays, e.g. in PacketListModel::recordLessThan.
|
||||
const QString PacketListRecord::columnString(capture_file *cap_file, int column, bool colorized)
|
||||
|
@ -57,6 +77,11 @@ const QString PacketListRecord::columnString(capture_file *cap_file, int column,
|
|||
return QString();
|
||||
}
|
||||
|
||||
//
|
||||
// XXX - do we still need to check the colorization, given that we now
|
||||
// have the ensureColorized() method to ensure that the record is
|
||||
// properly colorized?
|
||||
//
|
||||
bool dissect_color = ( colorized && !colorized_ ) || ( color_ver_ != rows_color_ver_ );
|
||||
if (column >= col_text_.count() || col_text_.at(column).isNull() || data_ver_ != col_data_ver_ || dissect_color) {
|
||||
dissect(cap_file, dissect_color);
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
PacketListRecord(frame_data *frameData);
|
||||
virtual ~PacketListRecord();
|
||||
|
||||
// Ensure that the record is colorized.
|
||||
void ensureColorized(capture_file *cap_file);
|
||||
// Return the string value for a column. Data is cached if possible.
|
||||
const QString columnString(capture_file *cap_file, int column, bool colorized = false);
|
||||
frame_data *frameData() const { return fdata_; }
|
||||
|
|
Loading…
Reference in New Issue