From dc3aa26dd3acbe76d4dd91910d03927776db8eb1 Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Fri, 22 Apr 2016 15:49:52 -0400 Subject: Qt UAT: call the UAT update callback after each field is updated. This fixes a crash when changing the SCCP dissector's users table when finishing the edit of a string column by clicking elsewhere (rather than pressing Enter/Return) or when changing an enum column. (The SCCP dissector depends on that update callback being called before the copy callback.) To do this: 1) Use the editingFinished signal rather than looking for Enter/Return key presses (so that a focus change is processed as the end of an edit). 2) Call the update callback when an enum field changes. Bug: 12364 Change-Id: I1884c67b6e873b46afe33703581d0b3dccbbdaf1 Reviewed-on: https://code.wireshark.org/review/15059 Petri-Dish: Jeff Morriss Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/uat_dialog.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/qt/uat_dialog.cpp b/ui/qt/uat_dialog.cpp index c3f39a8c1d..f5bce2fd3b 100644 --- a/ui/qt/uat_dialog.cpp +++ b/ui/qt/uat_dialog.cpp @@ -129,9 +129,6 @@ void UatDialog::keyPressEvent(QKeyEvent *evt) switch (evt->key()) { case Qt::Key_Escape: cur_line_edit_->setText(saved_string_pref_); - /* Fall Through */ - case Qt::Key_Enter: - case Qt::Key_Return: stringPrefEditingFinished(); return; default: @@ -321,6 +318,7 @@ void UatDialog::on_uatTreeWidget_itemActivated(QTreeWidgetItem *item, int column cur_line_edit_->selectAll(); connect(cur_line_edit_, SIGNAL(destroyed()), this, SLOT(lineEditPrefDestroyed())); connect(cur_line_edit_, SIGNAL(textChanged(QString)), this, SLOT(stringPrefTextChanged(QString))); + connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(stringPrefEditingFinished())); } if (cur_combo_box_) { editor = cur_combo_box_; @@ -389,12 +387,25 @@ void UatDialog::enumPrefCurrentIndexChanged(int index) g_free(err); ok_button_->setEnabled(false); uat_update_record(uat_, rec, FALSE); + } else if (uat_ && uat_->update_cb) { + field->cb.set(rec, enum_txt.constData(), (unsigned) enum_txt.size(), field->cbdata.set, field->fld_data); + + if (!uat_->update_cb(rec, &err)) { + QString err_string = "%1"; + ui->hintLabel->setText(err_string.arg(err)); + g_free(err); + ok_button_->setEnabled(false); + } else { + ui->hintLabel->clear(); + ok_button_->setEnabled(true); + } } else { ui->hintLabel->clear(); field->cb.set(rec, enum_txt.constData(), (unsigned) enum_txt.size(), field->cbdata.set, field->fld_data); ok_button_->setEnabled(true); uat_update_record(uat_, rec, TRUE); } + this->update(); uat_->changed = TRUE; } @@ -478,6 +489,7 @@ void UatDialog::stringPrefEditingFinished() this->update(); } + cur_line_edit_ = NULL; updateItem(*item); } -- cgit v1.2.1