[PyKDE] Issue with QDialog and lifetime
Giovanni Bajo
rasky at develer.com
Thu Jul 7 14:14:25 BST 2005
Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> 1. Either add an optional parameter to exec_loop() which does the transfer
> or have exec_loop_and_transfer() (or something less of a mouthful). At
> least that way it won't break existing code.
I like this solution. Then I can do:
class QDialog(QDialog):
exec_loop = QDialog.exec_loop_and_transfer
sys.modules["qt"].__dict__("QDialog") = QDialog
> Either way, I don't think it can be done (to my satisfaction)
> transparently. The programmer is going to have to be aware of the issue
> and explicitly deal with it.
For the backward compatibility issue, PyQt4 looks like a good point of
change. I can't help though with the consistency issue you raised:
consistency is in fact important, but non-leaking code is important too. I
suggest you sacrifice a little consistency in PyQt4 and make this the
default behaviour, together with a exec_loop_and_not_transfer() (or
exec_loop(False)).
I believe however is trained enough to understand the lifetime issues in
PyQt can also cope with QDialog's exec_loop transferring ownership by
default. Instead, those who do not master the lifetime issues will just have
their code working with no leaks without thinking of this.
--
Giovanni Bajo
More information about the PyQt
mailing list