[Interest] QImage::copy threadsafe?
maitai
maitai at virtual-winds.org
Sat Nov 9 20:01:18 CET 2019
Many thanks for the interesting answer
As you can guess the thing is that I have a very rare crash that I am
not able to reproduce in debug conditions, so after many hours starring
at the code I saw that as a possible explanation.
I'll try to make a copy, I am reluctant because I must be very careful
with memory and time to copy.
Philippe.
Le 09-11-2019 18:12, Giuseppe D'Angelo via Interest a écrit :
> Hi,
>
> On 08/11/2019 18:33, maitai wrote:
>> All is in the tile, is QImage::copy threadsafe? The method is const
>> but
>> is it enough? Documentation does not state it is thread safe so I am
>> wondering.
>>
>> My case is I have a QImage loaded in the main thread, and many many
>> threads that keep extracting small rectangles from it using
>> QImage::copy. No other operations occur on the QImage once loaded.
>
> The short story is that const methods on Qt value classes are
> generally thread safe. The exceptions are very very few (e.g.
> QString::utf16).
>
> I don't believe this is guaranteed anywhere in the documentation,
> though. If you can live with the "implementation guarantee" then, by
> all means, just use copy() from multiple threads.
>
> On the other hand, you could just create copies of the image and give
> them out to each worker thread. Copying a QImage is very cheap (it's
> implicitly shared so it won't deep copy the data anyhow).
>
> HTH,
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list