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: Icf22986cd5f6fd086518c78a7d56e6cadfe9f5f6
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
end = nameRegExps.constEnd();
iter != end; ++iter) {
- if (iter->exactMatch(fileName)) {
+ QRegExp copy = *iter;
+ if (copy.exactMatch(fileName)) {
matched = true;
break;
}
if (!parent || !list)
return;
const QObjectList &children = parent->children();
+ QRegExp reCopy = re;
QObject *obj;
for (int i = 0; i < children.size(); ++i) {
obj = children.at(i);
- if (mo.cast(obj) && re.indexIn(obj->objectName()) != -1)
+ if (mo.cast(obj) && reCopy.indexIn(obj->objectName()) != -1)
list->append(obj);
if (options & Qt::FindChildrenRecursively)
return (m_pattern == filename);
// Other (quite rare) patterns, like "*.anim[1-9j]": use slow but correct method
- const QRegExp rx(m_pattern, Qt::CaseSensitive, QRegExp::WildcardUnix);
+ QRegExp rx(m_pattern, Qt::CaseSensitive, QRegExp::WildcardUnix);
return rx.exactMatch(filename);
}
* replace that regexp is probably a 70 lines so I prioritize this to when
* the dependency is considered alarming, or when the rest of the bugs
* are fixed. */
- const QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*"));
+ QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*"));
Q_ASSERT(encNameRegExp.isValid());
return encNameRegExp.exactMatch(encName);