Qt: Fix default position when "Apply as Column"

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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2019-06-27 21:51:49 +02:00
parent fe5015f603
commit 44c5e62635
4 changed files with 6 additions and 6 deletions

View File

@ -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) {

View File

@ -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.
*

View File

@ -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);

View File

@ -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 )