From 27aacfb61e85a332394c7996f5c6603f07c28cd2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Dec 2017 12:46:11 +0100 Subject: QString: fix documentation of NUL-termination of unicode(), data(), constData() (or lack thereof). * `QString::utf16()` reallocates if `*this` has been constructed using `fromRawData()`. * `QString::data()` ensures a writable string, so will detach from raw data. * `QString::unicode()`, `constData()`, and `data() const` do not. They just return `QStringData::data()`, which may point to raw, non-NUL-terminated data. These functions can therefore not possibly have the same behavior, but were documented the same. Fix. Also drop the discussion of operator[](size()), as that, too, was not correct, and anyone who indexes with op[] beyond size() - 1 should not rely on proper behavior. [ChangeLog][QtCore][QString] QString::unicode(), constData() and `data() const` do not return a NUL-terminated string. This was true before, but the documentation claimed the opposite. Change-Id: I1437f57cd02bdf80264e8559608b46aa749c23a8 Reviewed-by: Thiago Macieira --- src/corelib/doc/snippets/qstring/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/corelib/doc/snippets') diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index c839c10b84..2ea75526df 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -733,7 +733,6 @@ void Widget::sizeFunction() int n = str.size(); // n == 5 str.data()[0]; // returns 'W' str.data()[4]; // returns 'd' - str.data()[5]; // returns '\0' //! [58] } -- cgit v1.2.3