[C++-sig] function that modifies an existing object

Engelbert Tijskens engelbert.Tijskens at biw.kuleuven.be
Mon May 9 14:56:29 CEST 2011


Hi, i need some help on this.

//c++
class Simulation
{
Simulation() {/*...*/}
run() {/**/}
};

void modifySimulation( Simulation & sim ) {/*...*/}

BOOST_PYTHON_MODULE(pySimulation)
{
    using namespace boost::python;
    class_<Simulation, boost::noncopyable>("Simulation")
        .def("run"  ,&Simulation_t::run )
     ;
	def("modifySimulation",modifySimulation);
}

#python
import pySimulation
sim = pySimulation.Simulation() #fine
modifySimulation(sim) #fine as well, I can debug it, and it does the right thing
sim.run() 

on this last statement the system crashes. python is basically telling me that sim is unbound. it seems to mee that the Simulation object is destroyed, but i cannot see why nor how i am supposed to prevent this using boost.python


More information about the Cplusplus-sig mailing list