Qt: Fix crash when changing dfilter macro

The comments claim that UAT_AFFECTS_FIELDS also triggers a redissection,
but it does not. Fortunately, all UATs whose flags have UAT_AFFECTS_FIELDS
also have UAT_AFFECTS_DISSECTION.

dfilter macro expressions are a rare case of a UAT that should trigger
FieldsChanged but not PacketDissectionChanged. (It's slightly
unnecessary to invalidate the custom columns, but perhaps in the
future macros will be possible in custom columns.)

So resolve things by changing the comments to reflect current reality
and making the dfilter macro UAT flags UAT_AFFECTS_FIELDS.

This prevents a crash when removing a dfilter macro thus invalidating
the current filter, and then opening a file (including reloading the
current one.)

Fix #13753
This commit is contained in:
John Thacker 2023-06-08 21:38:06 -04:00
parent 81c3ade8a3
commit a3806fc69b
4 changed files with 9 additions and 5 deletions

View File

@ -555,7 +555,7 @@ void dfilter_macro_init(void) {
TRUE,
&macros,
&num_macros,
0, /* doesn't affect anything that requires a GUI update */
UAT_AFFECTS_FIELDS,
"ChDisplayFilterMacrosSection",
macro_copy,
macro_update,

View File

@ -255,6 +255,10 @@ typedef struct _uat_field_t {
* Flags to indicate what the settings in this UAT affect.
* This is used when UATs are changed interactively, to indicate what needs
* to be redone when the UAT is changed.
*
* UAT_AFFECTS_FIELDS does *not* trigger a redissection, so usually one
* will also want UAT_AFFECTS_DISSECTION. A rare exception is changing
* the defined dfilter macros.
*/
#define UAT_AFFECTS_DISSECTION 0x00000001 /* affects packet dissection */
#define UAT_AFFECTS_FIELDS 0x00000002 /* affects what named fields exist */

View File

@ -344,11 +344,11 @@ void UatDialog::applyChanges()
if (!uat_) return;
if (uat_->flags & UAT_AFFECTS_FIELDS) {
/* Recreate list with new fields and redissect packets */
/* Recreate list with new fields */
mainApp->queueAppSignal(MainApplication::FieldsChanged);
}
if (uat_->flags & UAT_AFFECTS_DISSECTION) {
/* Just redissect packets if we have any */
/* Redissect packets if we have any */
mainApp->queueAppSignal(MainApplication::PacketDissectionChanged);
}
}

View File

@ -146,11 +146,11 @@ void UatFrame::applyChanges()
if (!uat_) return;
if (uat_->flags & UAT_AFFECTS_FIELDS) {
/* Recreate list with new fields and redissect packets */
/* Recreate list with new fields */
mainApp->queueAppSignal(MainApplication::FieldsChanged);
}
if (uat_->flags & UAT_AFFECTS_DISSECTION) {
/* Just redissect packets if we have any */
/* Redissect packets if we have any */
mainApp->queueAppSignal(MainApplication::PacketDissectionChanged);
}
}