diff --git a/ui/qt/models/packet_list_model.cpp b/ui/qt/models/packet_list_model.cpp index 0f81d093de..668c9070f7 100644 --- a/ui/qt/models/packet_list_model.cpp +++ b/ui/qt/models/packet_list_model.cpp @@ -8,6 +8,7 @@ */ #include +#include #include "packet_list_model.h" @@ -49,7 +50,6 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : idle_dissection_row_(0) { setCaptureFile(cf); - PacketListRecord::clearStringPool(); physical_rows_.reserve(reserved_packets_); visible_rows_.reserve(reserved_packets_); @@ -60,11 +60,14 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : this, &PacketListModel::emitItemHeightChanged, Qt::QueuedConnection); idle_dissection_timer_ = new QElapsedTimer(); + + string_cache_pool_ = g_string_chunk_new(1 * 1024 * 1024); } PacketListModel::~PacketListModel() { delete idle_dissection_timer_; + g_string_chunk_free(string_cache_pool_); } void PacketListModel::setCaptureFile(capture_file *cf) @@ -130,7 +133,7 @@ void PacketListModel::clear() { visible_rows_.resize(0); new_visible_rows_.resize(0); number_to_row_.resize(0); - PacketListRecord::clearStringPool(); + g_string_chunk_clear(string_cache_pool_); endResetModel(); max_row_height_ = 0; max_line_count_ = 1; @@ -697,7 +700,7 @@ void PacketListModel::dissectIdle(bool reset) // line counts? gint PacketListModel::appendPacket(frame_data *fdata) { - PacketListRecord *record = new PacketListRecord(fdata); + PacketListRecord *record = new PacketListRecord(fdata, string_cache_pool_); gint pos = -1; #ifdef DEBUG_PACKET_LIST_MODEL diff --git a/ui/qt/models/packet_list_model.h b/ui/qt/models/packet_list_model.h index 0e38152c05..bf44a721dc 100644 --- a/ui/qt/models/packet_list_model.h +++ b/ui/qt/models/packet_list_model.h @@ -111,6 +111,8 @@ private: QElapsedTimer *idle_dissection_timer_; int idle_dissection_row_; + struct _GStringChunk *string_cache_pool_; + bool isNumericColumn(int column); private slots: diff --git a/ui/qt/models/packet_list_record.cpp b/ui/qt/models/packet_list_record.cpp index ce90b77fb6..0d9da60b98 100644 --- a/ui/qt/models/packet_list_record.cpp +++ b/ui/qt/models/packet_list_record.cpp @@ -36,14 +36,15 @@ public: QMap PacketListRecord::cinfo_column_; unsigned PacketListRecord::col_data_ver_ = 1; -PacketListRecord::PacketListRecord(frame_data *frameData) : +PacketListRecord::PacketListRecord(frame_data *frameData, struct _GStringChunk *string_cache_pool) : col_text_(0), fdata_(frameData), lines_(1), line_count_changed_(false), data_ver_(0), colorized_(false), - conv_(NULL) + conv_(NULL), + string_cache_pool_(string_cache_pool) { } @@ -197,14 +198,6 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color) wtap_rec_cleanup(&rec); } -// This assumes only one packet list. We might want to move this to -// PacketListModel (or replace this with a wmem allocator). -struct _GStringChunk *PacketListRecord::string_pool_ = g_string_chunk_new(1 * 1024 * 1024); -void PacketListRecord::clearStringPool() -{ - g_string_chunk_clear(string_pool_); -} - //#define MINIMIZE_STRING_COPYING 1 void PacketListRecord::cacheColumnStrings(column_info *cinfo) { @@ -298,7 +291,7 @@ void PacketListRecord::cacheColumnStrings(column_info *cinfo) // https://git.gnome.org/browse/glib/tree/glib/gstringchunk.c // We might be better off adding the equivalent functionality to // wmem_tree. - col_text_->append(g_string_chunk_insert_const(string_pool_, col_str)); + col_text_->append(g_string_chunk_insert_const(string_cache_pool_, col_str)); for (int i = 0; col_str[i]; i++) { if (col_str[i] == '\n') col_lines++; } diff --git a/ui/qt/models/packet_list_record.h b/ui/qt/models/packet_list_record.h index 885dd403cf..d90d5aed52 100644 --- a/ui/qt/models/packet_list_record.h +++ b/ui/qt/models/packet_list_record.h @@ -31,7 +31,7 @@ class ColumnTextList; class PacketListRecord { public: - PacketListRecord(frame_data *frameData); + PacketListRecord(frame_data *frameData, struct _GStringChunk *string_cache_pool); // Allocate our records using wmem. static void *operator new(size_t size); @@ -52,8 +52,6 @@ public: inline int lineCount() { return lines_; } inline int lineCountChanged() { return line_count_changed_; } - static void clearStringPool(); - private: /** The column text for some columns */ ColumnTextList *col_text_; @@ -72,11 +70,11 @@ private: /** Conversation. Used by RelatedPacketDelegate */ struct conversation *conv_; + struct _GStringChunk *string_cache_pool_; + void dissect(capture_file *cap_file, bool dissect_color = false); + void cacheColumnStrings(column_info *cinfo); - - static struct _GStringChunk *string_pool_; - }; #endif // PACKET_LIST_RECORD_H