aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/packet_list.cpp1
-rw-r--r--ui/qt/packet_list_model.cpp40
-rw-r--r--ui/qt/packet_list_model.h8
3 files changed, 48 insertions, 1 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index d74b38d7ad..1407390bc6 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -735,6 +735,7 @@ void PacketList::setAutoScroll(bool enabled)
void PacketList::captureFileReadFinished()
{
packet_list_model_->flushVisibleRows();
+ packet_list_model_->dissectIdle(true);
}
void PacketList::freeze()
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp
index 70cc7f3f4e..6757fd75e2 100644
--- a/ui/qt/packet_list_model.cpp
+++ b/ui/qt/packet_list_model.cpp
@@ -40,6 +40,7 @@
#include "wireshark_application.h"
#include <QColor>
+#include <QElapsedTimer>
#include <QFontMetrics>
#include <QModelIndex>
#include <QElapsedTimer>
@@ -48,13 +49,20 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) :
QAbstractItemModel(parent),
uniform_row_heights_(true),
row_height_(-1),
- line_spacing_(0)
+ line_spacing_(0),
+ idle_dissection_row_(0)
{
setCaptureFile(cf);
PacketListRecord::clearStringPool();
connect(this, SIGNAL(itemHeightChanged(QModelIndex)),
this, SLOT(emitItemHeightChanged(QModelIndex)),
Qt::QueuedConnection);
+ idle_dissection_timer_ = new QElapsedTimer();
+}
+
+PacketListModel::~PacketListModel()
+{
+ delete idle_dissection_timer_;
}
void PacketListModel::setCaptureFile(capture_file *cf)
@@ -103,6 +111,7 @@ guint PacketListModel::recreateVisibleRows()
}
endInsertRows();
return visible_rows_.count();
+ idle_dissection_row_ = 0;
}
void PacketListModel::clear() {
@@ -114,6 +123,7 @@ void PacketListModel::clear() {
PacketListRecord::clearStringPool();
endResetModel();
uniform_row_heights_ = true;
+ idle_dissection_row_ = 0;
}
void PacketListModel::resetColumns()
@@ -532,6 +542,34 @@ void PacketListModel::flushVisibleRows()
}
}
+// Fill our column string and colorization cache while the application is
+// idle. Try to be as conservative with the CPU and disk as possible.
+static const int idle_dissection_interval_ = 5; // ms
+void PacketListModel::dissectIdle(bool reset)
+{
+ if (reset) {
+// qDebug() << "=di reset" << idle_dissection_row_;
+ idle_dissection_row_ = 0;
+ } else if (!idle_dissection_timer_->isValid()) {
+ return;
+ }
+
+ idle_dissection_timer_->restart();
+
+ while (idle_dissection_timer_->elapsed() < idle_dissection_interval_
+ && idle_dissection_row_ < physical_rows_.count()) {
+ ensureRowColorized(idle_dissection_row_);
+ idle_dissection_row_++;
+// if (idle_dissection_row_ % 1000 == 0) qDebug() << "=di row" << idle_dissection_row_;
+ }
+
+ if (idle_dissection_row_ < physical_rows_.count()) {
+ QTimer::singleShot(idle_dissection_interval_, this, SLOT(dissectIdle()));
+ } else {
+ idle_dissection_timer_->invalidate();
+ }
+}
+
// XXX Pass in cinfo from packet_list_append so that we can fill in
// line counts?
gint PacketListModel::appendPacket(frame_data *fdata)
diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h
index 8a41712555..7d5af30663 100644
--- a/ui/qt/packet_list_model.h
+++ b/ui/qt/packet_list_model.h
@@ -38,11 +38,14 @@
#include "cfile.h"
+class QElapsedTimer;
+
class PacketListModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
+ ~PacketListModel();
void setCaptureFile(capture_file *cf);
QModelIndex index(int row, int column,
const QModelIndex & = QModelIndex()) const;
@@ -86,6 +89,7 @@ public slots:
void setMonospaceFont(const QFont &mono_font, int row_height);
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void flushVisibleRows();
+ void dissectIdle(bool reset = false);
private:
capture_file *cap_file_;
@@ -106,6 +110,10 @@ private:
static capture_file *sort_cap_file_;
static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
+ QElapsedTimer *idle_dissection_timer_;
+ int idle_dissection_row_;
+
+
private slots:
void emitItemHeightChanged(const QModelIndex &ih_index);
};