forked from osmocom/wireshark
Qt: Add idle dissection.
Features such as sorting and scroll bar colorization require fully-dissected packets. We currently do dissection at the wrong time -- *after* the user clicks on a packet list column header or moves the scrollbar. Add a timer + slot that dissects packets when the UI is idle so that our packets are at least partially dissected when we need them. Change-Id: I024c590af2250d67404a520f118e46ec0c49cd71 Reviewed-on: https://code.wireshark.org/review/10593 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
4680c8b429
commit
50ff8ae0c7
|
@ -735,6 +735,7 @@ void PacketList::setAutoScroll(bool enabled)
|
|||
void PacketList::captureFileReadFinished()
|
||||
{
|
||||
packet_list_model_->flushVisibleRows();
|
||||
packet_list_model_->dissectIdle(true);
|
||||
}
|
||||
|
||||
void PacketList::freeze()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue