PDA

View Full Version : QThread and heap



paranoid_android
9th March 2006, 10:06
Hi.I've a question.
In my application I use a QThread to do some tasks and the thread allocates some object in the heap with new.
When i delete the thread does the objects allocated by this thread delete themself or i've to explicitly delete these objects in the thread decostructor to avoid that these objects remain in the memory till the termination of the application?

Sorry for my english :confused:

Thank you!!

wysota
9th March 2006, 10:14
I assume you didn't set QThread as parent of your custom objects. So the answer is -- yes, you have to delete them explicitely. You can use QThreadStorage to ease your task a little.

paranoid_android
9th March 2006, 11:13
Ok.Thanks.You know,the problem was that in that thread I do a download by mean of a QHttp object.

When i want to stop it i cannot do session->abort() o delete session because the application crashes so i was looking for a way to delete session (the QHttp object) and then the thread without get a crash.
It seems to work fine if in the thread decostructor i do session->deleteLater() but i have to call thread->wait before delete thread.

:rolleyes: