[C++-sig] Strange behavior when split modules
ericjardim at gmail.com
Thu Aug 18 15:22:41 CEST 2005
While wrapping the Qt4 code, I decided to split my single "Qt.so" module in
many modules (that by now are: Namespace, Core and Gui), and I am using a
package called Qt, that do some essential Python initializations on
Everything was Ok while spliting the modules, and it compiled Ok, and most
of my tests ran Ok. But a strange thing is happening!
There is a method called "parent" defined on the "QObject" class that
returns the object's parent (or None if not it exists) that is another
"QObject". As this is just a reference to a known object, I am using the
"return_value_policy<reference_existing_object>" policy. The "QObject" class
is defined on the "Core" module.
On the other hand. I have a lot of classes defined on the "Gui" module, that
are children (direct or indirect) of QObject. One of them, for example, is
the "QWidget" class. When I call "parent" from a "QWidget" object it return
an object with a different Python object, and I loose it's reference because
the refcount of that especific new Python object is lost. I also noted that
this behavior happend with other methods that return "non-new" objects.
All I have to say is that when modules were together in one this problem
didn't occur. To be sure of that, I just moved the QWidget class (and
QPaintDevice, that is another base class of QWidget) to the "Core" module,
and everything worked again.
So, am I not allowed to defined derived classes in different modules, or am
I doing something wrong?
By now, it is not a problem defining everything in a single module, but if
someone may want to write extension of the python-qt4 library, that would be
By the way, the project can be downloaded from:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cplusplus-sig