[PyQt] Deallocate QPaintDevice and descendants when worker thread ends

Jack Cosgrove jackcosgrove at gmail.com
Mon Jan 30 02:05:46 GMT 2012


Hi all,

I have an application in which I embed a Python interpreter in a worker
thread, and execute PyQT code using that interpreter. I was having some
issues with memory leaks, so I want to deallocate all PyQT objects
created by the worker thread when the worker thread ends. Using the Qt
memory management system I thought it would be straightforward to assign
the current QThread as the parent to all QObjects, but in the case of
QImage - derived from QPaintDevice - there looks to be no parent
parameter.

The GUI thread which spawns the worker thread contains its own Qt event
loop, so I want to be sure that the lifetime of PyQT objects is
determined by the lifetime of the worker thread and not the GUI thread.

How would I go about deallocating all of the objects derived from
QPaintDevice created by a worker thread when the thread ends?

-Jack



More information about the PyQt mailing list