From 44c5e62635e646b3b6933563ec59a749c19fd0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Thu, 27 Jun 2019 21:51:49 +0200 Subject: [PATCH] Qt: Fix default position when "Apply as Column" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default position for a column when "Apply as Column" is before the Info column if this is last, else add last. This bug was introduced in g5ae259c4. Change-Id: I68adaec5092e0ed1c65e771f171c42000fdc83fc Reviewed-on: https://code.wireshark.org/review/33759 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall Reviewed-by: Stig Bjørlykke --- ui/preference_utils.c | 6 +++--- ui/preference_utils.h | 2 +- ui/qt/main_window.h | 2 +- ui/qt/main_window_slots.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/preference_utils.c b/ui/preference_utils.c index 5f8617f2ac..3ce241dc9e 100644 --- a/ui/preference_utils.c +++ b/ui/preference_utils.c @@ -156,11 +156,11 @@ prefs_store_ext_multiple(const char * module, GHashTable * pref_values) gint column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields, gint custom_occurrence) { - return column_prefs_add_custom_with_position(fmt, title, custom_fields, custom_occurrence, 0); + return column_prefs_add_custom_with_position(fmt, title, custom_fields, custom_occurrence, -1); } gint -column_prefs_add_custom_with_position(gint fmt, const gchar *title, const gchar *custom_fields, gint custom_occurrence, guint position) +column_prefs_add_custom_with_position(gint fmt, const gchar *title, const gchar *custom_fields, gint custom_occurrence, gint position) { GList *clp; fmt_data *cfmt, *last_cfmt; @@ -184,7 +184,7 @@ column_prefs_add_custom_with_position(gint fmt, const gchar *title, const gchar cfmt->visible = TRUE; clp = g_list_last(prefs.col_list); last_cfmt = (fmt_data *) clp->data; - if (position <= (guint) colnr) { + if (position > 0 && position <= colnr) { /* Custom fields may be added at any position, depending on the given argument */ prefs.col_list = g_list_insert(prefs.col_list, cfmt, position); } else if (last_cfmt->fmt == COL_INFO) { diff --git a/ui/preference_utils.h b/ui/preference_utils.h index f2905bad25..791eb55b1b 100644 --- a/ui/preference_utils.h +++ b/ui/preference_utils.h @@ -85,7 +85,7 @@ gint column_prefs_add_custom_with_position(gint fmt, const gchar *title, const gchar *custom_fields, gint custom_occurrence, - guint position); + gint position); /** Remove a column. * diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 5a5da269eb..9f6cf1061c 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -129,7 +129,7 @@ public: QString getMwFileName(); void setMwFileName(QString fileName); - void insertColumn(QString name, QString abbrev, unsigned int pos = 0); + void insertColumn(QString name, QString abbrev, gint pos = -1); protected: virtual bool eventFilter(QObject *obj, QEvent *event); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index c7a6e8ac6b..3e84b215b3 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -3771,7 +3771,7 @@ void MainWindow::showExtcapOptionsDialog(QString &device_name) } } -void MainWindow::insertColumn(QString name, QString abbrev, unsigned int pos) +void MainWindow::insertColumn(QString name, QString abbrev, gint pos) { gint colnr = 0; if ( name.length() > 0 && abbrev.length() > 0 )