Details
-
User Story
-
Resolution: Fixed
-
P2: Important
-
None
-
None
-
af8f9a2a6 (dev)
Description
In our projects, we use the AAA (almost-always auto) style, which gives us trouble when we enable QStringBuilder:
// without QStringBuilder: auto s2 = s + QString::fromLatin1("foo"); // ok, s2 is a QString label.setText(s2); // with QStringBuilder auto s2 = s + QString::fromLatin1("foo"); // oops, s2 is a QStringBuilder<QString, QString> // temporary returned fromLatin1() destroyed now label.setText(s2); // conversion to actual QString here, accesses deleted data
I like how QStringTokenizer doesn't have this problem, and I think the same technique used there can also be used in QStringBuilder.
Attachments
Issue Links
- relates to
-
QTBUG-47066 Segmentation fault with QStringBuilder
- Closed
-
QTBUG-87603 Crash when concatenating two strings using QT_USE_QSTRINGBUILDER
- Closed
-
QTBUG-104354 Document QStringBuilder's auto gotcha
- Closed
-
QTBUG-103090 Make QStringBuilder mandatory
- Open
-
QTBUG-74873 Make QStringBuilder default on Qt6
- Closed
For Gerrit Dashboard: QTBUG-99291 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
479775,16 | QStringBuilder: allow to be used with 'auto' keyword | dev | qt/qtbase | Status: MERGED | +2 | 0 |