[PyQt] Bug in QTableView.setModel()
Hans-Peter Jansen
hpj at urpla.net
Tue Jan 8 15:19:49 GMT 2008
First of all, happy new year, Phil & and PyQtnistas!
Am Dienstag, 8. Januar 2008 schrieb Phil Thompson:
>
> In C++ you should be managing the lifecycle of the model you create
> (either by giving it a parent or by keeping a pointer to it and deleting
> it when appropriate). The same applies in PyQt. If you don't do so then
> you have a bug in your code.
Aaron, please get used to it: PyQt is a _Qt_ binding, and we all profit from
the fact, that we're able to apply all major Qt concepts directly to PyQt
(apart from a few absolutely necessary deviations), which may have some
weaknesses, but in general that proved to be the most effective and
successful approach to _create_ and _use_ the leading toolkit available
today from our beloved programming language.. In this way, we get the best
from two distinct worlds.
If you want to change the concept in question, you either:
- convince Trolltech, that there concept is weak, and help them to find a
way to apply your approach in a backwards compatible way. Good luck.
- create a patch to PyQt, and prove to us, that you were able to keep
the behaviour apart from keeping the reference to the model. That means,
there's no loss of flexibility, no memory leak, etc.
> The difference is that in C++ the effect of
> the bug is a memory leak, but in PyQt it is often a crash.
This part is what bugs me, and surely caught every PyQt user in one or
another way. Is there a technically feasible way to warn a user about
loosing a python reference of an still existing Qt object, probably
controllable by a sip function.
Pete
More information about the PyQt
mailing list