[Development] Unnecessary ambiguity in Qt documentation about reentrancy and safety of const methods.
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Sun Jul 19 01:05:17 CEST 2026
On 19/07/2026 00:38, NIkolai Marchenko wrote:
> I am not exactly sure if your wording covers the
> qlocale::toDouble(string,bool&) or not. aka non const but also
> partially not same data.
Well, the signature is
> double QLocale::toDouble(const QString &s, bool *ok = nullptr) const
Therefore, in the extended contract, it's OK to call this function from
multiple threads, without synchronization, on the same QLocale object
and/or on the same QString object. It's not OK to call it on the same
bool object.
Without the extended contract, do note that it's formally illegal to
call this function on the same QString instance, even if called on
different QLocale instances. toDouble() could call something like
`s.utf16()` internally, which isn't thread-safe.
My 2 c,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4850 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20260719/1d71f87e/attachment-0001.bin>
More information about the Development
mailing list