[PyKDE] Issue with QDialog and lifetime

Giovanni Bajo rasky at develer.com
Thu Jun 23 08:19:19 BST 2005


James Emerton <ephelon at gmail.com> wrote:

> Sorry to be digging up such an old thread, but my mind keeps coming
> back to this one.

Yeah, me too... I still have not conceived an elegant solution for this
problem. BTW, I also found out that this:

dlg = MyDialog(self):
try:
    dlg.exec_loop()
finally:
    dlg.deleteLater()

is not correct because there will be a leak in case MyDialog's constructor
throws an exception (after having called the C++ constructor, and so having
connected the instance to the parent).

> Does anyone see a potential problem with exec_loop() transferring
> ownership of the dialog instance back to Python?

Well, which C++ API would you intend to call to achieve this? We still need the
QDialog to keep its parent widget because it is the widget on which the dialog
is modal.

Giovanni Bajo




More information about the PyQt mailing list