[PyKDE] Embedding sip

Phil Thompson phil at river-bank.demon.co.uk
Wed Mar 7 21:09:18 GMT 2001


Christian Bird wrote:
> 
> Hi Phil,
> 
> I've got a question for you about the sip library.  We're embedding python running
> pyqt into a C++ application
> (wierd, I know, but python allows for a lot of flexibilty and coupled with Qt, it's
> great!)  We're running into problems
> with the sip library and hope that you might have a suggestion.  We stop and
> restart the python interpreter many
> times throughout the our program and after the first time, when we start up the
> interpreter, siplib has problems.
> It complains that:
> 
> RuntimeError: SIP - module "qt" implements QObject but it has already been
> implemented
> 
> I'm guessing that since sip is implemented in C and not python that maybe some
> things are left laying around
> when we stop the python interpreter and when it starts up again and imports qt, sip
> notices some remnants
> from the last time it was used.  I would guess that we just need to make sure that
> everything is cleaned up
> in sip when the embedded python interpreter closes.  Do you have any ideas of
> things we could try to get this
> working?  I've included a small test program that demonstrates the problem.  Thanks
> for your help.

Your understanding is correct. I've just committed some changes to SIP
that means it now tidies itself up properly (I think) when Py_Finalize()
is called.

But... your example now seg faults in the interpreter, and I'm not sure
where the problem is.

However... I'm not sure this is going to get you anywhere as I'm not
sure Qt is going to be happy about being "restarted" - particularly
QApplication.

BTW, I'm using Python v2.1b1.

Phil




More information about the PyQt mailing list