aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-10-28 05:58:53 -0400
committerJohn Thacker <johnthacker@gmail.com>2023-10-31 01:49:57 +0000
commit2adc59ff92fbde4a6313b6efbd97a5d708bcbde7 (patch)
tree475107d3dc840ded72ca399eebff8cfad23f44fc /ui/qt
parentd300f3046932c2b6e4f26c1dc8aa432b24aaf8a1 (diff)
Prefs: Fix TCP sequence analysis override pref handling
When a preference dialog is used, we don't want to write to each frame data the value of the TCP sequence analysis override preference immediately, because that means that the changes take effect even if the dialog is Rejected. The redissection isn't triggered, but that's worse in some ways, because it puts things in an inconsistent state. Instead, stash the list of frame datas to possibly override in the pref, and then override them when unstashing preferences. Delete the least when cleaning the preferences. (Storing the pointers should be fine, because the preference dialogs are modal.) This also allows us to correctly have the TCP sequence analysis override preference report whether or not any frame data's override value was changed, and avoids doing a full redissection any time the preference dialog is opened, even if nothing is changed. The TCP sequence analysis override preference doesn't need to be written to a file or read from the file or command line, because it's different for every frame, and reset to default (0) for each new frame when a file is read. Related to #17629
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/module_preferences_scroll_area.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/ui/qt/module_preferences_scroll_area.cpp b/ui/qt/module_preferences_scroll_area.cpp
index 56503e0ad3..49146e8a80 100644
--- a/ui/qt/module_preferences_scroll_area.cpp
+++ b/ui/qt/module_preferences_scroll_area.cpp
@@ -471,11 +471,27 @@ void ModulePreferencesScrollArea::updateWidgets()
}
if (prefs_get_type(pref) == PREF_PROTO_TCP_SNDAMB_ENUM && !prefs_get_enum_radiobuttons(pref)) {
- MainWindow* topWidget = dynamic_cast<MainWindow*> (mainApp->mainWindow());
- /* Ensure there is one unique or multiple selections. See issue 18642 */
- if (topWidget->hasSelection() || topWidget->hasUniqueSelection()) {
- frame_data * fdata = topWidget->frameDataForRow((topWidget->selectedRows()).at(0));
- enum_cb->setCurrentIndex(fdata->tcp_snd_manual_analysis);
+ if (prefs_get_list_value(pref, pref_stashed) == NULL) {
+ /* We haven't added a list of frames that could have their
+ * analysis changed. Set the current value to whatever the
+ * first selected frame has for its its TCP Sequence Analysis
+ * override.
+ */
+ MainWindow* topWidget = qobject_cast<MainWindow*>(mainApp->mainWindow());
+ /* Ensure there is one unique or multiple selections. See issue 18642 */
+ if (topWidget->hasSelection() || topWidget->hasUniqueSelection()) {
+ frame_data * fdata = topWidget->frameDataForRow((topWidget->selectedRows()).at(0));
+ enum_cb->setCurrentIndex(enum_cb->findData(fdata->tcp_snd_manual_analysis));
+ QList<int> rows = topWidget->selectedRows();
+ foreach (int row, rows) {
+ frame_data * fdata = topWidget->frameDataForRow(row);
+ prefs_add_list_value(pref, fdata, pref_stashed);
+ }
+ }
+ } else {
+ /* The initial value was already set from the selected frames,
+ * use the current value from when the CB was changed. */
+ enum_cb->setCurrentIndex(enum_cb->findData(prefs_get_enum_value(pref, pref_current)));
}
}
}
@@ -640,20 +656,8 @@ void ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged_PROTO_TCP(int
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
if (!pref) return;
- MainWindow* topWidget = dynamic_cast<MainWindow*> (mainApp->mainWindow());
-
- // method 1 : apply to one single packet
- /* frame_data * fdata = topWidget->frameDataForRow((topWidget->selectedRows()).at(0));
- fdata->tcp_snd_manual_analysis = enum_cb->itemData(index).toInt();*/
-
- // method 2 : we can leverage the functionality by allowing multiple selections
- QList<int> rows = topWidget->selectedRows();
- foreach (int row, rows) {
- frame_data * fdata = topWidget->frameDataForRow(row);
- fdata->tcp_snd_manual_analysis = enum_cb->itemData(index).toInt();
- }
-
+ // Store the index value in the current value, not the stashed value.
+ // We use the stashed value to store the frame data pointers.
prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_current);
//prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_stashed);
- updateWidgets();
}