[Interest] Never ending thread: blocking GUI
andre at familiesomers.nl
Wed Oct 17 10:05:12 CEST 2012
Op 17-10-2012 1:15, Lincoln Ramsay schreef:
> On 17/10/12 01:00, Sensei wrote:
>> So, if in my main thread every time I need to search I will create a
>> thread, a searcher, move the searcher to the new thread.
> You should probably just keep these objects around rather than
> recreating them all the time.
>> Am I leaking memory?
>> How can I delete these objects?
> Unfortunately, it's a little more complicated to clean up threads.
> Here's a suggestion.
It's not all that difficult, actually.
You can just connect the finished() signal of the QThread to the
deleteLater slot of the object you have as your worker in your thread.
Since Qt 4.8, that is save to do. All you need to do then, is if you
quit your application (or the part where this is relevant), you also
call quit() on your worker thread.
More information about the Interest