From 1044d56e3dd2b029a13964badc28da7d16d19b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 20 Feb 2018 10:05:48 +0100 Subject: [PATCH] Qt: Improve sorting of custom columns with multiple fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the already parsed col_custom_fields_ids to loop all fields in custom columns. Change-Id: I937e10e087feadc788591f2e3d49568611fda69b Reviewed-on: https://code.wireshark.org/review/25918 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- ui/qt/models/packet_list_model.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ui/qt/models/packet_list_model.cpp b/ui/qt/models/packet_list_model.cpp index 3601427e2e..4c5d4dc6e5 100644 --- a/ui/qt/models/packet_list_model.cpp +++ b/ui/qt/models/packet_list_model.cpp @@ -365,16 +365,11 @@ bool PacketListModel::isNumericColumn(int column) return false; } - gchar **fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX, - sort_cap_file_->cinfo.columns[column].col_custom_fields, - G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED); + guint num_fields = g_slist_length(sort_cap_file_->cinfo.columns[column].col_custom_fields_ids); + for (guint i = 0; i < num_fields; i++) { + guint *field_idx = (guint *) g_slist_nth_data(sort_cap_file_->cinfo.columns[column].col_custom_fields_ids, i); + header_field_info *hfi = proto_registrar_get_nth(*field_idx); - for (guint i = 0; i < g_strv_length(fields); i++) { - if (!*fields[i]) { - continue; - } - - header_field_info *hfi = proto_registrar_get_byname(fields[i]); /* * Reject a field when there is no numeric field type or when: * - there are (value_string) "strings" @@ -392,12 +387,10 @@ bool PacketListModel::isNumericColumn(int column) (hfi->type == FT_DOUBLE) || (hfi->type == FT_FLOAT) || (hfi->type == FT_BOOLEAN) || (hfi->type == FT_FRAMENUM) || (hfi->type == FT_RELATIVE_TIME))) { - g_strfreev(fields); return false; } } - g_strfreev(fields); return true; }