diff --git a/serialization/indexedstring.h b/serialization/indexedstring.h --- a/serialization/indexedstring.h +++ b/serialization/indexedstring.h @@ -159,7 +159,14 @@ QString str() const; /** - * Convenience function, avoid using it, it's relatively expensive (less expensive then str() though) + * Convenience function, cheap + * + * @note The bytes are *not* copied. The caller guarantees that this IndexedString is not deleted/modified as long as + * the returned QByteArray or any copies of it exist that have not been modified. + * + * @return Returns a QByteArray representing the underlying c string + * + * @sa QByteArray::fromRawData() */ QByteArray byteArray() const; diff --git a/serialization/indexedstring.cpp b/serialization/indexedstring.cpp --- a/serialization/indexedstring.cpp +++ b/serialization/indexedstring.cpp @@ -103,7 +103,7 @@ inline QByteArray arrayFromItem(const IndexedStringData* item) { const unsigned short* textPos = (unsigned short*)(item+1); - return QByteArray((char*)textPos, item->length); + return QByteArray::fromRawData((char*)textPos, item->length); } inline const char* c_strFromItem(const IndexedStringData* item) {