diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2016-04-22 15:49:52 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-04-24 06:46:27 +0000 |
commit | dc3aa26dd3acbe76d4dd91910d03927776db8eb1 (patch) | |
tree | 5591d5e3d81b50836de7be9257196644af9a299a /ui/qt/uat_dialog.cpp | |
parent | e19babfc55fb7442f6d765eb76538b847623be41 (diff) |
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 <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/uat_dialog.cpp')
-rw-r--r-- | ui/qt/uat_dialog.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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 = "<font color='red'>%1</font>"; + 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); } |