Browse Source

minor refcount tweak

David Rose 21 years ago
parent
commit
5a7bafe065
1 changed files with 6 additions and 0 deletions
  1. 6 0
      direct/src/distributed/cConnectionRepository.cxx

+ 6 - 0
direct/src/distributed/cConnectionRepository.cxx

@@ -390,7 +390,13 @@ handle_update_field() {
       DCClass *dclass = (DCClass *)PyInt_AsLong(dclass_this);
       DCClass *dclass = (DCClass *)PyInt_AsLong(dclass_this);
       Py_DECREF(dclass_this);
       Py_DECREF(dclass_this);
 
 
+      // It's a good idea to ensure the reference count to distobj is
+      // raised while we call the update method--otherwise, the update
+      // method might get into trouble if it tried to delete the
+      // object from the doId2do map.
+      Py_INCREF(distobj);
       dclass->receive_update(distobj, _di); 
       dclass->receive_update(distobj, _di); 
+      Py_DECREF(distobj);
     }
     }
   }
   }
 #endif  // HAVE_PYTHON  
 #endif  // HAVE_PYTHON