aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2019-10-02 19:25:12 +0200
committerAnders Broman <a.broman58@gmail.com>2019-10-04 15:47:49 +0000
commite7f5ba6aa7d6d56a7c375c02c911f61fc257d51f (patch)
treefb0f3b3370c60df94a2283d35d796c9ff96f8875
parent9e686f1e43b567d92b2a25a40a6b04726d2de839 (diff)
Qt: Do not redissect packets before sorting
There's no need to perform redissection as we are sorting data already present in PacketListRecord. This change is not only improving performance, but prevents a crash related to "event interruptions". As wsApp->processEvents() is called with QEventLoop::AllEvents, it is possible for user to trigger any action. If the user decided to close the file while packets are being redissected inside PacketListModel::sort(), Wireshark would crash. Ping-Bug: 16097 Change-Id: I82eee0efc789a1102e5fbe3670ed79039a18b8be Reviewed-on: https://code.wireshark.org/review/34679 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/models/packet_list_model.cpp24
1 files changed, 1 insertions, 23 deletions
diff --git a/ui/qt/models/packet_list_model.cpp b/ui/qt/models/packet_list_model.cpp
index 2375d4c370..1b9e29d0de 100644
--- a/ui/qt/models/packet_list_model.cpp
+++ b/ui/qt/models/packet_list_model.cpp
@@ -352,7 +352,6 @@ QElapsedTimer busy_timer_;
const int busy_timeout_ = 65; // ms, approximately 15 fps
void PacketListModel::sort(int column, Qt::SortOrder order)
{
- // packet_list_store.c:packet_list_dissect_and_cache_all
if (!cap_file_ || visible_rows_.count() < 1) return;
if (column < 0) return;
@@ -361,29 +360,8 @@ void PacketListModel::sort(int column, Qt::SortOrder order)
sort_order_ = order;
sort_cap_file_ = cap_file_;
- gboolean stop_flag = FALSE;
QString col_title = get_column_title(column);
- busy_timer_.start();
- emit pushProgressStatus(tr("Dissecting"), true, true, &stop_flag);
- int row_num = 0;
- foreach (PacketListRecord *row, physical_rows_) {
- row->columnString(sort_cap_file_, column);
- row_num++;
- if (busy_timer_.elapsed() > busy_timeout_) {
- if (stop_flag) {
- emit popProgressStatus();
- return;
- }
- emit updateProgressStatus(row_num * 100 / physical_rows_.count());
- // What's the least amount of processing that we can do which will draw
- // the progress indicator?
- wsApp->processEvents(QEventLoop::AllEvents, 1);
- busy_timer_.restart();
- }
- }
- emit popProgressStatus();
-
// XXX Use updateProgress instead. We'd have to switch from std::sort to
// something we can interrupt.
if (!col_title.isEmpty()) {
@@ -391,7 +369,7 @@ void PacketListModel::sort(int column, Qt::SortOrder order)
emit pushBusyStatus(busy_msg);
}
- busy_timer_.restart();
+ busy_timer_.start();
sort_column_is_numeric_ = isNumericColumn(sort_column_);
std::sort(physical_rows_.begin(), physical_rows_.end(), recordLessThan);