Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
8
-
Team 2 Foundation_Sprint 48, Team Two Foundation Sprint 49, Team Two Foundation Sprint 50, Team Two Foundation Sprint 51
Description
The utf16() function guarantees a NUL-terminated UTF-16 string, and will reallocate when it can't be sure (most prominently, from objects constructed fromRawData()). Some code uses this function just because it returns a ushort* instead of a (const) QChar*, to avoid a reinterpret_cast, but invokes the detach() path for common QString objects such as {{QStringLiteral}}s.
So, search for, and replace with QString::(const)data(), all uses of QString::utf16() that don't actually need the NUL-termination.
QStringView::utf16() is not affected, and should stay.
The casual use of utf16() has caused QTBUG-98653. Who knows what else is brewing.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-98763 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
383707,2 | QRegularExpression: don't detach() a pattern QStringLiteral | dev | qt/qtbase | Status: MERGED | +2 | 0 |
388355,1 | Replace uses of QString::utf16 with QString::data where appropriate | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |
388576,8 | Replace QString::utf16() with data() in memcpy() and QByteArray ctor | dev | qt/qtbase | Status: MERGED | +2 | 0 |
388664,5 | Use ranged for loops instead of QString::utf16 | dev | qt/qtbase | Status: MERGED | +2 | 0 |
388945,8 | Replace QString::utf16 with QString::data where appropriate | dev | qt/qtbase | Status: MERGED | +2 | 0 |
389019,3 | Replace QString with QStringView and use qsizetype in QPdfEnginePrivate | dev | qt/qtbase | Status: MERGED | +2 | 0 |
411515,2 | QString: don't use utf16() just to create a u16string | dev | qt/qtbase | Status: MERGED | +2 | 0 |
411622,2 | QString: don't use utf16() just to create a u16string | 6.3 | qt/qtbase | Status: MERGED | +2 | 0 |