diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-04-20 14:59:30 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-24 19:36:55 +0200 |
commit | 092118855ba47a0061e5b54198c49c3ad05b5aed (patch) | |
tree | 0c8279ca66b389979b02d37620a4866f21daf7da /src/gui/util | |
parent | fd7e1cef9cc06a2e36d98942c6e929ee5589952e (diff) | |
download | qtbase-092118855ba47a0061e5b54198c49c3ad05b5aed.tar.gz |
Don't use the QRegExp methods that modify the object [QtGui]
QRegExp matching methods modify the object, which we don't want to. In
particular, when we receive a QRegExp from the user or we store in a
context that might require thread-safety, make sure we make a copy
before using it.
QRegularExpression has no such shortcoming.
Task-number: QTBUG-25064
Change-Id: If119e06221ca99e57c5ad1a1d4cc6468e9f68c7b
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r-- | src/gui/util/qvalidator.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index d0bd1cfc6d..3103cc7424 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -871,10 +871,11 @@ QRegExpValidator::~QRegExpValidator() QValidator::State QRegExpValidator::validate(QString &input, int& pos) const { - if (r.exactMatch(input)) { + QRegExp copy = r; + if (copy.exactMatch(input)) { return Acceptable; } else { - if (const_cast<QRegExp &>(r).matchedLength() == input.size()) { + if (copy.matchedLength() == input.size()) { return Intermediate; } else { pos = input.size(); |