diff options
author | Guy Harris <guy@alum.mit.edu> | 2020-03-15 23:23:43 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2020-03-16 06:51:50 +0000 |
commit | 8e76178fcd9ac415ee8552399ca550ae8e27d8f5 (patch) | |
tree | 40c929d698c01366d46e05d8b711c6c523061f1f | |
parent | eb7774e4c12e636c47049fdb1add80507311d2a2 (diff) |
Fix reporting of interface-list-fetching errors.
If the attempt to fetch the list of local interfaces failed, the model
will be empty, so "model is empty" doesn't imply "no interfaces found".
First, check whether there was an error, and report the error string;
otherwise, if the list is empty, report "No interfaces found." (and fix
the capitalization while we're at it) and, otherwise, return an empty
string.
Also, if pcap support wasn't configured in at compile time, skip all
that, and just return a string indicating that.
Change-Id: I498226888272e1bdede2355cc902f8a74b0cce72
Reviewed-on: https://code.wireshark.org/review/36446
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | ui/qt/models/interface_tree_model.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp index 27a329b317..270020200c 100644 --- a/ui/qt/models/interface_tree_model.cpp +++ b/ui/qt/models/interface_tree_model.cpp @@ -61,19 +61,36 @@ InterfaceTreeModel::~InterfaceTreeModel(void) QString InterfaceTreeModel::interfaceError() { - QString errorText; - if (rowCount() == 0) +#ifdef HAVE_LIBPCAP + // + // First, see if there was an error fetching the interfaces. + // If so, report it. + // + if (global_capture_opts.ifaces_err != 0) { - errorText = tr("No Interfaces found."); + return tr(global_capture_opts.ifaces_err_info); } -#ifdef HAVE_LIBPCAP - else if (global_capture_opts.ifaces_err != 0) + + // + // Otherwise, if there are no rows, there were no interfaces + // found. + // + if (rowCount() == 0) { - errorText = tr(global_capture_opts.ifaces_err_info); + return tr("No interfaces found."); } -#endif - return errorText; + // + // No error. Return an empty string. + // + return ""; +#else + // + // We were built without pcap support, so we have no notion of + // local interfaces. + // + return tr("This version of Wireshark was built without packet capture support."); +#endif } int InterfaceTreeModel::rowCount(const QModelIndex &) const |