Kakadu / lablqml

Interfacing Qt/QML with OCaml. Formely known as lablqt
http://kakadu.github.io/lablqml
GNU Lesser General Public License v2.1
159 stars 17 forks source link

Deep copying of Qt objects #50

Open ghost opened 7 years ago

ghost commented 7 years ago

It is not clear if: https://github.com/Kakadu/lablqml/blob/orbifx/object-subclass/lib/stubs/variant.c#L13

is making a deep copy of the string.

Might be better to use QVariant(const *char) which explicitly states deep copy.

It's not clear if: https://github.com/Kakadu/lablqml/blob/orbifx/object-subclass/lib/stubs/variant.c#L32

is thread safe.

ghost commented 7 years ago

variant.c#L32 probably doesn't matter since it will return a variant with deep copied data, within the scope of that function.

ghost commented 7 years ago

I think this answers the QString part. @Kakadu ?

Kakadu commented 7 years ago

So it does copying. It seems docs are correct :) http://doc.qt.io/qt-5/qstring.html#QString-7

ghost commented 7 years ago

The docs are ambiguous when one is doubtful. They say that most Qt containers work with shallow copies but then they don't always highlight in the constructor documentation if and when it does deep-copying, although it does.

This is all ok, till a cross-thread, cross-memory-manager, corruption occurs and then everything is doubtful.

Of course Qt's documentation is written for those working within certain scope of the framework.