aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/interface_toolbar.cpp
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-08-24 16:16:34 +0200
committerAnders Broman <a.broman58@gmail.com>2017-08-28 14:41:43 +0000
commit8873c7e494018637449a17a7f7ddaf88ad43f3c6 (patch)
tree162c283b967e7dc5f98a54575ff2ed25444997a8 /ui/qt/interface_toolbar.cpp
parent76c231bd683410bed4fa803bcbc91e613e201ab0 (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/interface_toolbar.cpp')
-rw-r--r--ui/qt/interface_toolbar.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/ui/qt/interface_toolbar.cpp b/ui/qt/interface_toolbar.cpp
index ffddf28f50..fed9cb919b 100644
--- a/ui/qt/interface_toolbar.cpp
+++ b/ui/qt/interface_toolbar.cpp
@@ -951,20 +951,20 @@ void InterfaceToolbar::interfaceListChanged()
for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++)
{
- interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.hidden)
+ interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (device->hidden)
continue;
- if (interface_.keys().contains(device.name))
+ if (interface_.keys().contains(device->name))
{
- ui->interfacesComboBox->addItem(device.name);
- if (selected_ifname.compare(device.name) == 0)
+ ui->interfacesComboBox->addItem(device->name);
+ if (selected_ifname.compare(device->name) == 0)
{
// Keep selected interface
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- ui->interfacesComboBox->setCurrentText(device.name);
+ ui->interfacesComboBox->setCurrentText(device->name);
#else
- int new_index = ui->interfacesComboBox->findText(device.name);
+ int new_index = ui->interfacesComboBox->findText(device->name);
if (new_index >= 0)
{
ui->interfacesComboBox->setCurrentIndex(new_index);