PDA

View Full Version : clear emited signal queue



bibhukalyana
5th May 2011, 08:20
Hi everyone,
I am using 3 thread in my program.One is gui thread and rest 2 are non-gui thread(x,y).From one non gui thread(x) i am continuously emitting image to gui thread for display.From that same thread i am also emitting the image to the other non gui thread(y) for some operation.There is a button on gui thread & on click it emits a signal to y.Now i want to do this operation immediately but it is taking time due to all emitted signals are queued.
Is there any way to clean the queue or increase the priority or any other way to do this?

MarekR22
5th May 2011, 08:43
Hi you have a problem that consumer is slower then producer and you want to ignore some slot calls.
I suspect that this kind of solution would be for you ok for you.

class Consumer ...
{

private:
bool processingImage;
QImage image;
};

void Consumer::procesImageSlot(QImage newImage)
{
image = newImage; // store data of this call (newest data)
if (processingImage)
return; // ignore this call, slot call is already in progress
processingImage = true; // mark that slot is processed
QApplication::processEvents(); // process remaining slot calls (events) until event queue is empty

processImageNow(image);

processingImage = false; // mark that processing has ended
}

bibhukalyana
5th May 2011, 10:20
thanks
it is working.