aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-08-28 10:38:31 +0200
committerPeter Wu <peter@lekensteyn.nl>2017-08-28 16:53:32 +0000
commit879920a2ebaacf33e554ab47e340c34fe2e878d8 (patch)
treee7be37cd3912c5bf3146c52f0fe114170b1b3bdf
parent8646596829494dbe054a18958eac68682ba42721 (diff)
iface_lists: Remove locked field
It seems the locked field of interface_t was used to avoid simultaneous updates of interface entries from either multiple threads or most likely the recursive UI update callbacks case later identified. Since 802362e ("Avoid recursive scan_local_interfaces operation") the recursive callback behavior is no longer happening. And as code does not have consistent checks the locked field can anyway hardly protect a multi-threaded case if such a case exists. Remove the unnecessary locked field. Ping-Bug: 13864 Change-Id: Idc393f702b82aa6014dd636572d00f0d67120bf3 Reviewed-on: https://code.wireshark.org/review/23262 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--capture_opts.h1
-rw-r--r--ui/gtk/capture_dlg.c18
-rw-r--r--ui/gtk/capture_if_dlg.c31
-rw-r--r--ui/gtk/main_welcome.c39
-rw-r--r--ui/iface_lists.c2
-rw-r--r--ui/qt/capture_filter_syntax_worker.cpp2
-rw-r--r--ui/qt/capture_interfaces_dialog.cpp13
-rw-r--r--ui/qt/models/interface_tree_model.cpp22
8 files changed, 50 insertions, 78 deletions
diff --git a/capture_opts.h b/capture_opts.h
index 311cc4ac97..8d38cac607 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -200,7 +200,6 @@ typedef struct interface_tag {
if_info_t if_info;
gboolean selected;
gboolean hidden;
- gboolean locked;
#ifdef HAVE_EXTCAP
/* External capture cached data */
GHashTable *external_cap_args_settings;
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 363746d2a3..f1e66cbcce 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -3088,7 +3088,6 @@ static void toggle_callback(GtkCellRendererToggle *cell _U_,
guint i;
/* Initialise device */
- device.locked = FALSE;
device.cfilter = NULL;
if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
@@ -3105,15 +3104,12 @@ static void toggle_callback(GtkCellRendererToggle *cell _U_,
break;
}
}
- if (!device.locked) {
- if (enabled == FALSE) {
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- } else {
- device.selected = FALSE;
- global_capture_opts.num_selected--;
- }
- device.locked = TRUE;
+ if (enabled == FALSE) {
+ device.selected = TRUE;
+ global_capture_opts.num_selected++;
+ } else {
+ device.selected = FALSE;
+ global_capture_opts.num_selected--;
}
if (indx != -1) {
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, indx);
@@ -3151,7 +3147,6 @@ static void toggle_callback(GtkCellRendererToggle *cell _U_,
device.cfilter = NULL;
update_filter_string(device.name, NULL);
}
- device.locked = FALSE;
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, indx);
g_array_insert_val(global_capture_opts.all_ifaces, indx, device);
gtk_tree_path_free (path);
@@ -3518,7 +3513,6 @@ add_pipe_cb(gpointer w _U_)
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
device.active_dlt = -1;
- device.locked = FALSE;
device.if_info.name = g_strdup(g_save_file);
device.if_info.friendly_name = NULL;
device.if_info.vendor_description = NULL;
diff --git a/ui/gtk/capture_if_dlg.c b/ui/gtk/capture_if_dlg.c
index 52dc5cd566..187b704662 100644
--- a/ui/gtk/capture_if_dlg.c
+++ b/ui/gtk/capture_if_dlg.c
@@ -172,24 +172,19 @@ store_selected(GtkWidget *choose_bt, gpointer name)
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (strcmp((char *)name, device.if_info.name) == 0) {
- if (!device.locked) {
- device.selected ^= 1;
- if (device.selected) {
- global_capture_opts.num_selected++;
- } else {
- global_capture_opts.num_selected--;
- }
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
- change_interface_selection(device.name, device.selected);
- }
- if (gtk_widget_is_focus(choose_bt) && capture_dlg_window_present()) {
- enable_selected_interface(device.name, device.selected);
- }
- device.locked = FALSE;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ device.selected ^= 1;
+ if (device.selected) {
+ global_capture_opts.num_selected++;
+ } else {
+ global_capture_opts.num_selected--;
+ }
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
+ change_interface_selection(device.name, device.selected);
+ }
+ if (gtk_widget_is_focus(choose_bt) && capture_dlg_window_present()) {
+ enable_selected_interface(device.name, device.selected);
}
break;
}
diff --git a/ui/gtk/main_welcome.c b/ui/gtk/main_welcome.c
index a37593fe4b..a776425926 100644
--- a/ui/gtk/main_welcome.c
+++ b/ui/gtk/main_welcome.c
@@ -737,32 +737,25 @@ on_selection_changed(GtkTreeSelection *selection _U_,
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (strcmp(device.name, if_name) == 0) {
- if (!device.locked) {
- if (path_currently_selected) {
- if (device.selected) {
- device.selected = FALSE;
- global_capture_opts.num_selected--;
- }
- } else {
- if (!device.selected) {
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- }
- }
- device.locked = TRUE;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
-
- if (capture_dlg_window_present()) {
- enable_selected_interface(g_strdup(if_name), device.selected);
+ if (path_currently_selected) {
+ if (device.selected) {
+ device.selected = FALSE;
+ global_capture_opts.num_selected--;
}
- if (interfaces_dialog_window_present()) {
- update_selected_interface(g_strdup(if_name));
+ } else {
+ if (!device.selected) {
+ device.selected = TRUE;
+ global_capture_opts.num_selected++;
}
- device.locked = FALSE;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
}
+ if (capture_dlg_window_present()) {
+ enable_selected_interface(g_strdup(if_name), device.selected);
+ }
+ if (interfaces_dialog_window_present()) {
+ update_selected_interface(g_strdup(if_name));
+ }
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
break;
}
}
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index 97ecb24462..a989317d11 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -182,7 +182,6 @@ scan_local_interfaces(void (*update_cb)(void))
device.friendly_name = NULL;
}
device.hidden = FALSE;
- device.locked = FALSE;
memset(&temp, 0, sizeof(temp));
temp.name = g_strdup(if_info->name);
temp.friendly_name = g_strdup(if_info->friendly_name);
@@ -381,7 +380,6 @@ scan_local_interfaces(void (*update_cb)(void))
device.last_packets = 0;
device.links = NULL;
device.local = TRUE;
- device.locked = FALSE;
device.if_info.name = g_strdup(interface_opts->name);
device.if_info.friendly_name = NULL;
device.if_info.vendor_description = g_strdup(interface_opts->descr);
diff --git a/ui/qt/capture_filter_syntax_worker.cpp b/ui/qt/capture_filter_syntax_worker.cpp
index a578643b50..b61f6dbbb4 100644
--- a/ui/qt/capture_filter_syntax_worker.cpp
+++ b/ui/qt/capture_filter_syntax_worker.cpp
@@ -92,7 +92,7 @@ void CaptureFilterSyntaxWorker::start() {
interface_t *device;
device = &g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx);
- if (!device->locked && device->selected) {
+ if (device->selected) {
#ifdef HAVE_EXTCAP
if (device->if_info.extcap == NULL || strlen(device->if_info.extcap) == 0) {
#endif
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp
index 72cb2eba6f..5e31fed8a7 100644
--- a/ui/qt/capture_interfaces_dialog.cpp
+++ b/ui/qt/capture_interfaces_dialog.cpp
@@ -249,14 +249,11 @@ void CaptureInterfacesDialog::updateGlobalDeviceSelections()
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_name.compare(QString().fromUtf8(device->name)) == 0) {
- if (!device->locked) {
- if ((*iter)->isSelected()) {
- device->selected = TRUE;
- global_capture_opts.num_selected++;
- } else {
- device->selected = FALSE;
- }
- device->locked = FALSE;
+ if ((*iter)->isSelected()) {
+ device->selected = TRUE;
+ global_capture_opts.num_selected++;
+ } else {
+ device->selected = FALSE;
}
break;
}
diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp
index 0f8cd29a1c..c57859ad72 100644
--- a/ui/qt/models/interface_tree_model.cpp
+++ b/ui/qt/models/interface_tree_model.cpp
@@ -512,20 +512,16 @@ bool InterfaceTreeModel::updateSelectedDevices(QItemSelection sourceSelection)
for ( unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++ )
{
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx);
- if ( !device->locked )
+ if ( selectedIndices.contains(idx) )
{
- if ( selectedIndices.contains(idx) )
- {
- if (! device->selected )
- selectionHasChanged = true;
- device->selected = TRUE;
- global_capture_opts.num_selected++;
- } else {
- if ( device->selected )
- selectionHasChanged = true;
- device->selected = FALSE;
- }
- device->locked = FALSE;
+ if (! device->selected )
+ selectionHasChanged = true;
+ device->selected = TRUE;
+ global_capture_opts.num_selected++;
+ } else {
+ if ( device->selected )
+ selectionHasChanged = true;
+ device->selected = FALSE;
}
}
#else