QRE: discourage users from assuming that QRE stores the subject
When matching over a QString we store a (shallow) copy of it. That has always been an implementation detail and people should've never relied on it, but Hyrum's law, we don't want to actually exploit this by NOT taking the copy. Converesely, matching over QStringView already requires that the string data is kept alive as long as QRE(Match) objects are alive. Add a doc note to give us the freedom to do the change in Qt 7. [ChangeLog][QtCore][QRegularExpression] QRegularExpression takes a shallow copy of a QString subject when matching over it. This means that users can destroy or modify the string data while still having match results over it. This behavior is deprecated; in a future version of Qt, QRegularExpression will no longer take a copy. Note that behavior has always been undocumented and users were never supposed to modify a subject string while match objects were alive on it. In practice, it's very unlikely that your code is relying on the existing behavior. Change-Id: Ibc5f900c09a007139fb12fc4d7f11e4a8f31bf38 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
1ebccf3426
commit
427da06414
|
|
@ -1571,6 +1571,11 @@ qsizetype QRegularExpression::patternErrorOffset() const
|
|||
The returned QRegularExpressionMatch object contains the results of the
|
||||
match.
|
||||
|
||||
\note The data referenced by \a subject should remain valid as long
|
||||
as there are QRegularExpressionMatch objects using it. At the moment
|
||||
Qt makes a (shallow) copy of the data, but this behavior may change
|
||||
in a future version of Qt.
|
||||
|
||||
\sa QRegularExpressionMatch, {normal matching}
|
||||
*/
|
||||
QRegularExpressionMatch QRegularExpression::match(const QString &subject,
|
||||
|
|
@ -1628,6 +1633,11 @@ QRegularExpressionMatch QRegularExpression::match(QStringView subjectView,
|
|||
The returned QRegularExpressionMatchIterator is positioned before the
|
||||
first match result (if any).
|
||||
|
||||
\note The data referenced by \a subject should remain valid as long
|
||||
as there are QRegularExpressionMatch objects using it. At the moment
|
||||
Qt makes a (shallow) copy of the data, but this behavior may change
|
||||
in a future version of Qt.
|
||||
|
||||
\sa QRegularExpressionMatchIterator, {global matching}
|
||||
*/
|
||||
QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &subject,
|
||||
|
|
|
|||
Loading…
Reference in New Issue