Hi all,
2010/12/8 Matti Airas <[email protected]>:
> But it we had a property for that, like QObject::isValid(), we could
> simplify a lot this logic:
>
> if not self.layout.isValid(): self.layout = new QVBoxLayout(self.frame)
> self.layout.addWidget(self.newwidget)
>
> Of course this is not the right way to code, the developer should code in
> such a way that this "isValid()" function would be useless.. but anyway this
> will be very helpful to avoid bugs, or for some debugging purposes.
I think it's a helpful tool during development. Such features are
misused if exposed in the "public" API, and if we have this isValid()
on the QObject, it could confuse developers looking for e.g. a
validation method of their entry box (which is not at all that this is
about, but the name might suggest that in a specific context without
any knowledge that this feature exists).
My proposal: Add it as feature somewhere "outside" of the normal API
(e.g. PySide.debugging) like this:
from PySide import debugging
if debugging.qobject_deleted(my_widget):
print 'ohai deletion handling!'
A good idea might be that this "debugging" module is only available
when PySide is built with the debug target, not in the release target
(again, to avoid usage of this in "normal" code). On the other hand,
when the module is already named "debugging", it could be built in the
release target as well, as its name already suggests "this is
something you only want to use during a debugging session". AFAIUI
this is nice for when somebody wants to figure out when an object gets
deleted during development, but it should never be used in production
code for day-to-day usage. Of course, the naming and structure is up
for discussion :)
tl;dr: Make it available, but outside the "normal" APIs and maybe only
in debug builds.
HTH.
Thomas
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside