[Development] QString, QVariant and QSQLite

Alberto Mardegan mardy at users.sourceforge.net
Thu May 27 21:06:00 CEST 2021


On 27/05/21 11:50, Giuseppe D'Angelo via Development wrote:
> In the overwhelming majority of cases, utf16() won't make any
> allocation. There's just one exception -- if the QString was built via
> fromRawData(). In that case, in order to ensure NUL termination, utf16()
> does actually "detach" (even if it's a const method).

mmm... The string is created in QML and assigned to a property, like this:

    relationshipType: "Aggregates"

so I'm not sure if this uses fromRawData() or something else.

>> And why destroying a const QVariant causes the deallocation of the data
>> created by QString::utf16()??
> 
> QString::utf16 doesn't "create" data: it modifies the string *itself* so
> that it becomes detached and NUL terminated.

Sure, I meant s/created/allocated/

Anyway, I filed this bug:
https://bugreports.qt.io/browse/QTBUG-94070

Ciao,
  Alberto

-- 
http://www.mardy.it - Geek in un lingua international


More information about the Development mailing list