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>
This commit is contained in:
Jeff Morriss 2016-04-22 15:49:52 -04:00 committed by Anders Broman
parent e19babfc55
commit dc3aa26dd3
1 changed files with 15 additions and 3 deletions

View File

@ -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);
}