In some sip-wrapped C++ code I wrote, I have a class CALcontributionIterator 
containing a virtual function:

  virtual void log(unsigned tower, unsigned layer, CALlog log) = 0;

CALlog is a small class of 4 bytes that parses bit fields in its single 
unsigned data value.  SIP allows this log method can be implemented in Python 
code.

The iterate() method in this class calls the virtual log() method as:

      ...
      {
        CALlog theLog(datum);
        log(tower, layer, theLog);
      }
      ...

The sip for this class is pretty bland:

class CALcontributionIterator
{
%TypeHeaderCode
#include "CALcontributionIterator.h"
%End

public:
  CALcontributionIterator();
  ~CALcontributionIterator();

  unsigned iterate()  /ReleaseGIL/;

  virtual void log(unsigned /*tower*/, unsigned /*layer*/, CALlog /*log*/) = 0;
};

and for CALlog, as well:

class CALlog
{
%TypeHeaderCode
#include "CALlog.h"
%End

public:
  CALlog();
  ~CALlog();

  CALlogEnd negative() const;
  CALlogEnd positive() const;
};

Everything appears to work correctly other than that any Python usage of the 
CALlog object causes the program to leak memory.  What is the proper way to 
transfer ownership of the stack allocated CALlog object instance in this 
situation?

I'm using SIP 4.1.1 on Windows XP.

        Thanks,
                Ric

_______________________________________________
PyKDE mailing list    [EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to