[PyQt] PyQt. How to shoot yourself in the foot.

Yuya Nishihara yuya at tcha.org
Sun Aug 24 15:47:14 BST 2014


On Sun, 24 Aug 2014 15:06:32 +0300, Andrei Kopats wrote:
> I tried to use pyqtSlot on PyQt and Slot on PySide and got the same results.
> Maybe I missed something.
> https://github.com/hlamer/pyqt-memory-mgmt/blob/master/5-disconnect.py may
> be used to reproduce the exceptions and crashes.

I can't tell you why this example raises "C++ object deleted" error.  It worked
as expected with old-style connection:

   QTimer.singleShot(1000, lineEdit, SLOT('selectAll()'))

But I guess real-world cases of "C++ object deleted" error are caused by
different reason than this example.

General rules I have in mind are:

 a. manage connections by Qt as possible (no lambda, no dynamically-created
    function, etc.)
 b. don't create reference cycles that require Python GC, which is a cycle
    collector

Regards,


More information about the PyQt mailing list