diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-06-09 19:42:32 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-06-10 02:43:15 +0000 |
commit | 3c9c2c65341bae5a7b983af2a572b8a9a99b543c (patch) | |
tree | 84df0e7b4d965b7fc39bb9bc3f567a7081fa64f9 /ui | |
parent | 0fbb5f84d00426040bd37dd89d74e2ecda5b598e (diff) |
If device->active_dlt = -1, show "Unknown" rather than "DLT -1".
It means we don't know the active link-layer header type - probably
because the device can't be opened, so we can't get the default linktype
or the list of available linktypes - so show it as "Unknown".
Bug: 14847
Change-Id: I5a1ad360d2ae461e8db57e387679700a566b0949
Reviewed-on: https://code.wireshark.org/review/28185
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 20 | ||||
-rw-r--r-- | ui/qt/models/interface_tree_model.cpp | 20 |
2 files changed, 27 insertions, 13 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 5f705465cc..b5d8df20b5 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -109,13 +109,19 @@ public: QString default_str = QObject::tr("default"); - QString linkname = QObject::tr("DLT %1").arg(device->active_dlt); - for (GList *list = device->links; list != NULL; list = g_list_next(list)) { - link_row *linkr = (link_row*)(list->data); - // XXX ...and if they're both -1? - if (linkr->dlt == device->active_dlt) { - linkname = linkr->name; - break; + // XXX - this is duplicated in InterfaceTreeModel::data; + // it should be done in common code somewhere. + QString linkname; + if (device->active_dlt == -1) + linkname = "Unknown"; + else { + linkname = QObject::tr("DLT %1").arg(device->active_dlt); + for (GList *list = device->links; list != NULL; list = g_list_next(list)) { + link_row *linkr = (link_row*)(list->data); + if (linkr->dlt == device->active_dlt) { + linkname = linkr->name; + break; + } } } setText(col_link_, linkname); diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp index 2dea30ff4e..d2b7217284 100644 --- a/ui/qt/models/interface_tree_model.cpp +++ b/ui/qt/models/interface_tree_model.cpp @@ -158,12 +158,20 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const } else if ( col == IFTREE_COL_DLT ) { - QString linkname = QObject::tr("DLT %1").arg(device->active_dlt); - for (GList *list = device->links; list != NULL; list = g_list_next(list)) { - link_row *linkr = (link_row*)(list->data); - if (linkr->dlt != -1 && linkr->dlt == device->active_dlt) { - linkname = linkr->name; - break; + // XXX - this is duplicated in + // InterfaceTreeWidgetItem::updateInterfaceColumns; + // it should be done in common code somewhere. + QString linkname; + if (device->active_dlt == -1) + linkname = "Unknown"; + else { + linkname = QObject::tr("DLT %1").arg(device->active_dlt); + for (GList *list = device->links; list != NULL; list = g_list_next(list)) { + link_row *linkr = (link_row*)(list->data); + if (linkr->dlt == device->active_dlt) { + linkname = linkr->name; + break; + } } } |