Browse Source

even better fix: allow callback to save OdeGeom pointers

David Rose 15 years ago
parent
commit
6532984ea6
1 changed files with 5 additions and 5 deletions
  1. 5 5
      panda/src/ode/odeSpace.cxx

+ 5 - 5
panda/src/ode/odeSpace.cxx

@@ -256,11 +256,11 @@ collide(PyObject* arg, PyObject* callback) {
 
 
 void OdeSpace::
 void OdeSpace::
 near_callback(void *data, dGeomID o1, dGeomID o2) {
 near_callback(void *data, dGeomID o1, dGeomID o2) {
-  OdeGeom g1 (o1);
-  OdeGeom g2 (o2);
-  PyObject* p1 = DTool_CreatePyInstanceTyped(&g1, Dtool_OdeGeom, false, false, g1.get_type_index());
-  PyObject* p2 = DTool_CreatePyInstanceTyped(&g2, Dtool_OdeGeom, false, false, g2.get_type_index());
-  PyObject* result = PyEval_CallFunction(_python_callback, "OOO", (PyObject*) data, p1, p2);
+  OdeGeom *g1 = new OdeGeom(o1);
+  OdeGeom *g2 = new OdeGeom(o2);
+  PyObject *p1 = DTool_CreatePyInstanceTyped(g1, Dtool_OdeGeom, true, false, g1->get_type_index());
+  PyObject *p2 = DTool_CreatePyInstanceTyped(g2, Dtool_OdeGeom, true, false, g2->get_type_index());
+  PyObject *result = PyEval_CallFunction(_python_callback, "OOO", (PyObject*) data, p1, p2);
   if (!result) {
   if (!result) {
     odespace_cat.error() << "An error occurred while calling python function!\n";
     odespace_cat.error() << "An error occurred while calling python function!\n";
     PyErr_Print();
     PyErr_Print();