summaryrefslogtreecommitdiffstats
path: root/examples/serialbus/can
diff options
context:
space:
mode:
authorEvgeny Shtanov <shtanov_evgenii@mail.ru>2021-02-13 22:00:43 +0300
committerEvgeny Shtanov <shtanov_evgenii@mail.ru>2021-02-21 15:06:05 +0000
commit76a57dfe9fe96d03fb41280e0eaecd9927b94a32 (patch)
treeb6a7d29b23df9dcecfd0a61cd4852b8aac35767e /examples/serialbus/can
parent40f14eefbae29fb79960207c69ef7dd6cf80bfc7 (diff)
Can example: Fix crash in payload hex editor
[ChangeLog][CAN Example] Fixed a crash in the payload hex editor when deleting characters in the middle. Fixes: QTBUG-90783 Change-Id: I95d1f1826c6d19195c2538b6adf214a9d9d5f47f Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'examples/serialbus/can')
-rw-r--r--examples/serialbus/can/sendframebox.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/serialbus/can/sendframebox.cpp b/examples/serialbus/can/sendframebox.cpp
index 980548b..0c3babc 100644
--- a/examples/serialbus/can/sendframebox.cpp
+++ b/examples/serialbus/can/sendframebox.cpp
@@ -112,10 +112,12 @@ QValidator::State HexStringValidator::validate(QString &input, int &pos) const
return Invalid;
// insert a space after every two hex nibbles
- const QRegularExpression insertSpace(QStringLiteral("(?:[[:xdigit:]]{2} )*[[:xdigit:]]{3}"));
- if (insertSpace.match(input).hasMatch()) {
- input.insert(input.size() - 1, space);
- pos = input.size();
+ const QRegularExpression threeDigits(QStringLiteral("[[:xdigit:]]{3}"));
+
+ while (threeDigits.match(input).hasMatch()) {
+ const QRegularExpressionMatch match = threeDigits.match(input);
+ input.insert(match.capturedEnd() - 1, space);
+ pos = match.capturedEnd() + 1;
}
return Acceptable;