From 8e76178fcd9ac415ee8552399ca550ae8e27d8f5 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 15 Mar 2020 23:23:43 -0700 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- ui/qt/models/interface_tree_model.cpp | 33 +++++++++++++++++++++++++-------- 1 file 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 -- cgit v1.2.3