[PyKDE] Sipping from unknown classes
David Boddie
david at boddie.org.uk
Sun Jul 13 23:42:01 BST 2003
I've run into an interesting situation with my attempts to pass a QWidget
into a Python function which is run in an embedded interpreter.
I begin by receiving a pointer to a QWidget and a reference to a QString:
KPanelApplet* return_instance( QWidget *parent, const QString& configFile )
Later, I extract a char array from the QString and put it in a tuple to
be passed to the Python function. I try to create a Python QWidget object
from the pointer to the QWidget passed and this works, but only when the
pointer is 0 (NULL). This is what I do (noting that pArg1 is a PyObject*):
pArgs = PyTuple_New(3);
pArg1 = sipMapCppToSelfSubClass(parent, sipClass_QWidget);
When parent is 0 the function receives a parameter containing None, which is
what I'd expect, although I was surprised not to be dealing with a valid
QWidget. However, when KDE starts up and initialises the panel, it all falls
apart with the following (edited) backtrace:
0x410d0f29 in wait4 () from /lib/libc.so.6
#0 0x410d0f29 in wait4 () from /lib/libc.so.6
#1 0x41151234 in __DTOR_END__ () from /lib/libc.so.6
#2 0x40ee6103 in waitpid () from /lib/libpthread.so.0
#3 0x40633c4d in KCrash::defaultCrashHandler(int) ()
from /opt/kde/lib/libkdecore.so.4
#4 <signal handler called>
#5 0x417399a7 in findObjectIndex ()
from /usr//lib/python2.2/site-packages/libsip.so.9
#6 0x41739a40 in sipOMFindObject ()
from /usr//lib/python2.2/site-packages/libsip.so.9
#7 0x4173de6d in sipGetThisWrapper ()
from /usr//lib/python2.2/site-packages/libsip.so.9
#8 0x4173dded in sipMapCppToSelf ()
from /usr//lib/python2.2/site-packages/libsip.so.9
#9 0x4173de41 in sipMapCppToSelfSubClass ()
from /usr//lib/python2.2/site-packages/libsip.so.9
#10 0x416411c2 in return_instance (parent=0x80f2720, configFile=@0xbfffefb0)
at panel_launcher.cpp:142
#11 0x414223a9 in PluginLoader::loadApplet(AppletInfo const&, QWidget*) (
this=0x41429de0, info=@0xbffff070, parent=0x80f2720) at
pluginloader.cpp:78
The "panel_launcher.cpp:142" reference is the sipClass_QWidget line given
above. I've tried using sipMapCppToSelf here with the same result. It seems
odd that things appear to work when presented with a NULL pointer but not
when a presumably valid pointer is supplied.
What have I missed?
David
More information about the PyQt
mailing list