diff options
author | Mikael Kanstrup <mikael.kanstrup@gmail.com> | 2017-08-24 16:16:34 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-08-28 14:41:43 +0000 |
commit | 8873c7e494018637449a17a7f7ddaf88ad43f3c6 (patch) | |
tree | 162c283b967e7dc5f98a54575ff2ed25444997a8 /ui/qt/capture_preferences_frame.cpp | |
parent | 76c231bd683410bed4fa803bcbc91e613e201ab0 (diff) |
iface_lists: Access all_ifaces member by reference
Change access of all_ifaces elements from by val to by reference.
With this change unnecessary copying of the whole struct is avoided
but even more important is that elements no longer have to be
removed and inserted whenever data is updated.
This change aims to make it more clear that all_ifaces elements
shall never be removed from the array without freeing resources
via the capture_opts_free_interface_t function.
NOTE: Code for GTK UI not updated
Ping-Bug: 13864
Change-Id: I36742cb1d5c8daa136c9d3732a044a7c8e5c7fe7
Reviewed-on: https://code.wireshark.org/review/23201
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/capture_preferences_frame.cpp')
-rw-r--r-- | ui/qt/capture_preferences_frame.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ui/qt/capture_preferences_frame.cpp b/ui/qt/capture_preferences_frame.cpp index 0028902565..24804ed765 100644 --- a/ui/qt/capture_preferences_frame.cpp +++ b/ui/qt/capture_preferences_frame.cpp @@ -71,7 +71,7 @@ void CapturePreferencesFrame::showEvent(QShowEvent *) void CapturePreferencesFrame::updateWidgets() { #ifdef HAVE_LIBPCAP - interface_t device; + interface_t *device; QString default_device_string; if (prefs_get_string_value(pref_device_, pref_stashed)) { @@ -87,20 +87,20 @@ void CapturePreferencesFrame::updateWidgets() wsApp->refreshLocalInterfaces(); } for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); /* Continue if capture device is hidden */ - if (device.hidden) { + if (device->hidden) { continue; } - // InterfaceTree matches against device.name when selecting the + // InterfaceTree matches against device->name when selecting the // default interface, so add it here if needed. On Windows this // means that we show the user a big ugly UUID-laden device path. - // We might be able to work around that by passing device.name as + // We might be able to work around that by passing device->name as // the userData argument to addItem instead. - QString item_text = device.display_name; - if (!item_text.contains(device.name)) { - item_text.append(QString(" (%1)").arg(device.name)); + QString item_text = device->display_name; + if (!item_text.contains(device->name)) { + item_text.append(QString(" (%1)").arg(device->name)); } ui->defaultInterfaceComboBox->addItem(item_text); } |