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>
This commit is contained in:
Guy Harris 2020-03-15 23:23:43 -07:00
parent eb7774e4c1
commit 8e76178fcd
1 changed files with 26 additions and 9 deletions

View File

@ -61,19 +61,36 @@ InterfaceTreeModel::~InterfaceTreeModel(void)
QString InterfaceTreeModel::interfaceError()
{
QString errorText;
#ifdef HAVE_LIBPCAP
//
// First, see if there was an error fetching the interfaces.
// If so, report it.
//
if (global_capture_opts.ifaces_err != 0)
{
return tr(global_capture_opts.ifaces_err_info);
}
//
// Otherwise, if there are no rows, there were no interfaces
// found.
//
if (rowCount() == 0)
{
errorText = tr("No Interfaces found.");
return tr("No interfaces found.");
}
#ifdef HAVE_LIBPCAP
else if (global_capture_opts.ifaces_err != 0)
{
errorText = tr(global_capture_opts.ifaces_err_info);
}
#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