Hi,
I'm trying to find out how to wrap one class but I'm not sure how to
do it correctly...
I have a class which owns a geometry class. The geometry can be at
some point of time detached from the class (and deleted elsewhere):
class Feature
{
public:
[...]
// returns only reference
Geometry* getGeometry() { return geom; }
// marks that it's not responsible for geometry's deletion anymore
Geometry* getGeometryAndOwnership() { ownsGeometry = 0; return geom; }
// deletes the geometry if it's still owning it
~Feature() { if (ownsGeometry) delete geom; }
private:
bool ownsGeometry;
Geometry* geom;
};
My question is - what annotations should I use for the getter
functions? I guess I should use TransferBack for
getGeometryAndOwnership() as it takes the responsibility for deletion.
But what about getGeometry() ? When used without any annotation I have
a problem in this scenario:
1. feature is created
2. getGeometry is called and the reference is stored
3. feature is deleted
4. reference in python still exists but the object is deleted already...
Thanks,
Martin
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt