[Qt-interest] Problem drawning in the GUI Thread with Data from another Thread

O Caldas caldaz.sheep at gmail.com
Fri Jul 3 01:57:09 CEST 2009


> How do you call PopGraph::graphUpdate() ?

I have this slot

void DriverView::updateSlot(){
    if(graph != NULL) graph->graphUpdate();
}

and i call the signal: emit hasChanged();

every computation step. also they are connected by:
connect(this, SIGNAL(hasChanged()),this,SLOT(updateSlot()));


> If the thread's signal is firing fast enough, could there be a race
> condiditon between paintEvent()'s drawImage() using buffer, and
> deleting buffer in graphUpdate() ?

what do you mean by a race condition? you mean that the next painting
might be deleting the buffer of the previous painting?

> Does the application crash? And if so, do you know which line of code
crashes?
yes the application crashs, i will try to find out at wich line of code now.

thanks for the help!


2009/7/2 Srdjan Todorovic <todorovic.s at googlemail.com>

> Hi,
>
> 2009/7/3 O Caldas <caldaz.sheep at gmail.com>:
> > oh, and here is the code of the paintEvent() method:
> >
> > void PopGraph::paintEvent(QPaintEvent*){
> >     QPainter painter2(this);
> >     painter2.drawImage(QPoint(0,0), *buffer);
> > }
>
> How do you call PopGraph::graphUpdate() ?
>
> If the thread's signal is firing fast enough, could there be a race
> condiditon between paintEvent()'s drawImage() using buffer, and
> deleting buffer in graphUpdate() ?
>
> Does the application crash? And if so, do you know which line of code
> crashes?
>
> > buffer is an atribute QImage* of the class
>
> >> void PopGraph::graphUpdate(){
> >>     delete(buffer);
> >>     buffer = new QImage(size(), QImage::Format_ARGB32);
>
> >>     }
> >> //    if(contador == 1){
> >> //        contador =0;
> >>         update();
> >> }
>
> Srdjan
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
Daniel Mendes Caldas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090702/ec1d155b/attachment.html 


More information about the Qt-interest-old mailing list