From: Naveen K. <nav...@gm...> - 2008-08-16 05:01:47
|
Hi everyone, I have traced the problem to a modification i had been trying in python/boost_shared_ptr.i and did not revert back later. I'm very sorry i made a mistake of not testing with a fresh copy of SWIG 1.3.36 and the SVN version before jumping to conclusions. I apologize to everyone who has spent time trying to reproduce and fix this problem. And many thanks to Tonio for replying. I'm documenting the sequence of events which caused the problem for me so that it might be useful for someone else. During my migration from SWIG 1.3.33 to 1.3.36, i noticed a couple of new files Lib/shared_ptr.i. The reference doc at http://www.swig.org/Doc1.3/Python.html#Python_nn27 still showed the old overloaded -> operator approach only. At that time i did not know that the CHANGES file had example of how to use the SWIG_SHARED_PTR macro, instead i set out to do a trial and error method to find out how to use the new shared_ptr.i. Initially i did not know that the boost_shared_ptr.i should be included instead of shared_ptr.i, but after sometime i found the correct file. In my c++ code i'm using namespace similar to the example in CHANGES file namespace Space { struct Klass { ... }; } and during the first few attempts i was using the SWIG_SHARED_PTR like SWIG_SHARED_PTR(KlassPtr, Klass) this caused a compiler error like testPYTHON_wrap.cxx: In function 'PyObject* _wrap_delete_Klass(PyObject*, PyObject*)': testPYTHON_wrap.cxx:2636: error: 'smartarg1' was not declared in this scope i located the source of the above code to line: 11 in python/boost_shared_ptr.i and in order to isolate and understand the problem i commented out the %feature("unref") section, partially motivated by the already commented out line: 10. This did remove the compiler error for the time being. But after finding out the right way i made the mistake of not reverting back the change i had made. For the sake of search engines: if getting "error: 'smartarg1' was not declared in this scope" check if correct namespace has been used in the macro like SWIG_SHARED_PTR(KlassPtr, Space::Klass) On Sat, Aug 16, 2008 at 5:43 AM, Antoine PREVOT <ton...@ya...>wrote: > > As it can be seen in the output, the Inner destructor gets called when > > ever the python side object goes out of scope. > > Hi Naveen, > > I can't reproduce your example for now, but you should take a look at the > "thisown" property of your proxy class. The memory management section > (30.4.2) of the swig documentation may be helpful : > http://www.swig.org/Doc1.3/Python.html#Python_nn29 > > Best regards, > > Tonio > |