[Qt-interest] The dangers of removePostedEvents?

Mihail Naydenov mlists at ymail.com
Tue Dec 7 10:28:08 CET 2010



----- Original Message ----
> From: Mandeep Sandhu <mandeepsandhu.chd at gmail.com>
> To: Mihail Naydenov <mlists at ymail.com>
> Cc: Scott Aron Bloom <Scott.Bloom at onshorecs.com>; qt-interest at trolltech.com
> Sent: Tue, December 7, 2010 7:18:56 AM
> Subject: Re: [Qt-interest] The dangers of removePostedEvents?
> 
> On Mon, Dec 6, 2010 at 10:01 PM, Mihail Naydenov <mlists at ymail.com> wrote:
> > I am  trying to implement cancellation of work sent to a thread using (only)
> >  signals and slots method. (object movedToThread, slots do work and emit  
>results
> > back)
> >
> > My problem is if I queue many events I  have hard time forcing it to handle 
>only
> > the last one, discarding all  previous.
> >
> > (Though I already use a cancel flag, I fail to find a  way to set and restore 
>it
> > the right way, the above to happen. Another  issue is that most of the work
> > itself is not cancelable, so it mainly  handles stuff, like "don't start it" 
>or
> > "don't sent the result"  )
> 
> Would it work if there is a flag in the worker thread, set from  the
> main GUI thread, which the worker thread checks before emitting  the
> result. So, if this "discard result" flag is set, you simply  don't
> emit the result. Something similar is done in the mandlebrot  example
> (http://doc.qt.nokia.com/latest/threads-mandelbrot.html). The flag  can
> be unset once when the main thread is ready to accept the  results.

As said, I have already done that ("don't sent the result").
Problem is the queue of requests that has to be processed, but I don't want to.
Also, I do not use run() reimpl, just signals and slots, so things are a bit 
diff. then mandelbrot example.

thanks anyway
MihailNaydenov

> 
> HTH,
> -mandeep
> 


      



More information about the Qt-interest-old mailing list