[Qt-interest] Qt4.4.3 paintEvent thread-safe
Prasanta Sadhukhan
Prasanta.Sadhukhan at Sun.COM
Tue Dec 23 06:27:39 CET 2008
Andreas Pakulat wrote:
> On 22.12.08 14:43:42, Prasanta Sadhukhan wrote:
>
>> which got solved when I introduced a mutex lock and unlock inside my
>> PaintEvent function, like this
>>
>> void QtWindow::paintEvent(QPaintEvent *event)
>> {
>>
>> AWT_QT_LOCK;
>> QPainter p(this);
>> QPoint pt(0,0);
>> p.drawImage(pt, *QtImageDescPool[0].offscrSurface);
>>
>
> I guess this array is shared by both threads, the Qt-painting thread and
> the one that paints onto the offscreen image?
Yes
> If so, thats why you need the
> lock, which probably causes the slowdown. There are only 2 solutions here:
>
> a) provide a completely copy of the offscreen image to the qt-painting
> thread instead of using a global array (for example by using a custom Qt
> event that carries the QImage)
>
Can you please elaborate on this solution?
Thanks
Prasanta
> b) merge the code to have just 1 thread in the application.
>
> Andreas
>
>
More information about the Qt-interest-old
mailing list