aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/uat_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/uat_dialog.cpp')
-rw-r--r--ui/qt/uat_dialog.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/ui/qt/uat_dialog.cpp b/ui/qt/uat_dialog.cpp
index bd2ebe1f5d..98088c8d83 100644
--- a/ui/qt/uat_dialog.cpp
+++ b/ui/qt/uat_dialog.cpp
@@ -344,18 +344,12 @@ void UatDialog::applyChanges()
void UatDialog::acceptChanges()
{
- if (!uat_) return;
-
- if (uat_->changed) {
- gchar *err = NULL;
+ if (!uat_model_) return;
- if (!uat_save(uat_, &err)) {
- report_failure("Error while saving %s: %s", uat_->name, err);
- g_free(err);
- }
-
- if (uat_->post_update_cb) {
- uat_->post_update_cb();
+ QString error;
+ if (uat_model_->applyChanges(error)) {
+ if (!error.isEmpty()) {
+ report_failure("%s", qPrintable(error));
}
applyChanges();
}
@@ -363,15 +357,22 @@ void UatDialog::acceptChanges()
void UatDialog::rejectChanges()
{
- if (!uat_) return;
+ if (!uat_model_) return;
- if (uat_->changed) {
- gchar *err = NULL;
- uat_clear(uat_);
- if (!uat_load(uat_, NULL, &err)) {
- report_failure("Error while loading %s: %s", uat_->name, err);
- g_free(err);
+ QString error;
+ if (uat_model_->revertChanges(error)) {
+ if (!error.isEmpty()) {
+ report_failure("%s", qPrintable(error));
}
+ // Why do we have to trigger a redissection? If the original UAT is
+ // restored and dissectors only apply changes after the post_update_cb
+ // method is invoked, then it should not be necessary to trigger
+ // redissection. One potential exception is when something modifies the
+ // UAT file after Wireshark has started, but this behavior is not
+ // supported and causes potentially unnecessary redissection whenever
+ // the preferences dialog is closed.
+ // XXX audit all UAT providers and check whether it is safe to remove
+ // the next call (that is, when their update_cb has no side-effects).
applyChanges();
}
}