Check the validator in ExtArgText::isValid().
The validator doesn't prevent the input focus from being transferred out of the QLineEdit, and it merely prevents the user from entering a value that's considered "invalid" rather than "not valid but "intermediate"". For QIntValidator(), values that have more digits than the maximum value are "invalid", but values that have the same number of digits but that are larger are just "intermediate". This means the user will be able to send such a value to the extcap module. So we explicitly check the validator in ExtArgText::isValid(), so that 1) we provide visual feedback (at least to people who can detect a red background) for out-of-range values that don't have too many digits and 2) prevent them from being treated as valid and passed to the extcap module. Bug: 16510 Change-Id: Ie5b90cf5dbb57c91744f6a28a71674b65ef21bb6 Reviewed-on: https://code.wireshark.org/review/36914 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net> Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
48f87bc3ee
commit
ba50c5a5f6
|
@ -451,6 +451,34 @@ bool ExtArgText::isValid()
|
|||
if (isRequired() && value().length() == 0)
|
||||
valid = false;
|
||||
|
||||
/* Does the validator, if any, consider the value valid?
|
||||
*
|
||||
* If it considers it an "intermediate" value, rather than an "invalid"
|
||||
* value, the user will be able to transfer the input focus to another
|
||||
* widget, and, as long as all widgets have values for which isValid()
|
||||
* is true, they wil be able to click the "Start" button.
|
||||
*
|
||||
* For QIntValidator(), used for integral fields with minimum and
|
||||
* maximum values, a value that's larger than the maximum but has
|
||||
* the same number of digits as the maximum is "intermediate" rather
|
||||
* than "invalid", so the user will be able to cause that value to
|
||||
* be passed to the extcap module; see bug 16510.
|
||||
*
|
||||
* So we explicitly call the hasAcceptableInput() method on the
|
||||
* text box; that returns false if the value is not "valid", and
|
||||
* that includes "intermediate" values.
|
||||
*
|
||||
* This way, 1) non-colorblind users are informed that the value
|
||||
* is invalid by the text box background being red (perhaps the
|
||||
* user isn't fully colorblind, or perhaps the background is a
|
||||
* noticeably different grayscale), and 2) the user won't be able
|
||||
* to start the capture until they fix the problem.
|
||||
*
|
||||
* XXX - it might be nice to have some way of indicating to the
|
||||
* user what the problem is with the value - alert box? Tooltip? */
|
||||
if (!textBox->hasAcceptableInput())
|
||||
valid = false;
|
||||
|
||||
/* validation should only be checked if there is a value. if the argument
|
||||
* must be present (isRequired) the check above will handle that */
|
||||
if (valid && _argument->regexp != NULL && value().length() > 0)
|
||||
|
|
Loading…
Reference in New Issue