QString::utf8() - is it re-entrant or not?
-
In accordance with the Qt documentation for QString class
bq. All functions in this class are reentrant, except for ascii(), latin1(), utf8(), and local8Bit(), which are non-reentrant.
But the implementation of QString::utf8() is the following:
@ inline QT3_SUPPORT QByteArray utf8() const{ return toUtf8(); }
@So, the toUtf8() should be also non-reentrant.
The same situation with local8Bit().
My current understanding is that the documentation is incorrect. utf8() (and local8Bit()) should be removed from the list of non-reentrant functions.
Please confirm or provide additional clarifications.
Thanks
-
The warning has been introduced with "Qt 4.2.0":http://doc.qt.nokia.com/4.2/qstring.html. Both in "Qt 4.0.x":http://doc.qt.nokia.com/4.0/qstring-qt3.html and "4.1.x":http://doc.qt.nokia.com/4.1/qstring.html no method was marked as being not reentrant. I don't know the reason, the change logs for the release do not mention the change and I do not have a git log or something similar that could give a comment on it.
-
@peppe
Did you check the other methods with Thiago too?I would expect the following situation to be true:
@
// NOT reentrant:
inline QT3_SUPPORT const char *ascii() const { return ascii_helper(); }
inline QT3_SUPPORT const char *latin1() const { return latin1_helper(); }// actually reentrant but wrong in the docs
// these are just aliases for reentrant Qt4 methods
inline QT3_SUPPORT QByteArray utf8() const { return toUtf8(); }
inline QT3_SUPPORT QByteArray local8Bit() const{ return toLocal8Bit(); }
@