[PyQt] SIP Question (Not PyQT/PyKDE related)
jdoyon at NRCan.gc.ca
Thu Jul 5 16:48:06 BST 2007
Thanks a bunch, just go the snapshot, and things now work as expected.
One thing though re: reference passing:
I wanted Python to get the reference so that everything gest cleaned up
properly, so I added a /TransferBack/ (Actually /Out,TransferBack/) to
the method signature, only now glibc complains that free() is called on
an invalid pointer when the interpreter shuts down! Is that right?
I may end up using the C++ toolkit I'm wrapping a long-running, even
threaded process (a server), so I want to make sure I get this right.
From: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of Phil Thompson
Sent: July 4, 2007 16:25
To: pyqt at riverbankcomputing.com
Subject: Re: [PyQt] SIP Question (Not PyQT/PyKDE related)
On Wednesday 04 July 2007 8:37 pm, Doyon, Jean-Francois wrote:
> I've been using SIP to wrap a closed source binary SDK for Linux I
> have, with quite a bit of success considering I don't know much of C++
> (Kudos to the SIP team!).
> Now I have a slight problem that I'm not sure to address so I'm
> wondring if someone could point me in the right direction.
> I have the following signature:
> LT_STATUS getDataByIndex(lt_uint32 index, const LTIMetadataRecord*&
> record) const;
> Everything here is fine, except for that *& notation which I haven't
> come across before.
For SIP you need to add the /Out/ annotation to the record argument.
Current versions of SIP will then complain about using /Out/ with const
That will be fixed in tonight's snapshot.
> The example C++ code does something like this to use this method:
> for (i=0; i<numRecs; i++)
> const LTIMetadataRecord* rec = NULL;
> sts = db.getDataByIndex(i, rec);
If it's important that rec is initialised to NULL before calling
getDataByIndex() then you will have to do this with some %MethodCode.
> The problem for me is that LTIMetadataRecord does NOT have
> So I'm not sure what to pass getDataByIndex() for the second
> I tried something like:
> record = None
> db.getDataByIndex(index, record)
> print record
You will then use it like this...
sts, record = db.getDataByIndex(index)
> But "record" remains unchanged. Of course, I can't create an instance
> of LTIMetadataRecord, so I'm not sure how else to go about this.
> Any have an idea, or ideally, a recipe? (Or maybe there's an example
> of something like this in PyQT/PyKDE?)
> Any help would be much appreciated!
The other thing to note is that C++ owns the record, ie. it will not be
destroyed when the Python object is garbage collected. Use one of the
transfer annotations if you want to change that.
PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt