David Rose 16 years ago
parent
commit
33a94a3996

+ 0 - 1
direct/src/plugin/p3dPythonRun.cxx

@@ -1033,7 +1033,6 @@ pyobj_to_xml(PyObject *value) {
     }
 
     // Now that it's stored in the map, increment its reference count.
-    // TODO: implement removing things from this map.
     Py_INCREF(value);
 
     xvalue->SetAttribute("type", "python");

+ 0 - 1
direct/src/plugin/p3dSession.cxx

@@ -485,7 +485,6 @@ p3dobj_to_xml(P3D_object *obj) {
       }
 
       // Now that it's stored in the map, increment its reference count.
-      // TODO: implement removing things from this map.
       P3D_OBJECT_INCREF(obj);
 
       xvalue->SetAttribute("type", "browser");

+ 10 - 10
direct/src/plugin/p3d_plugin.cxx

@@ -124,21 +124,21 @@ P3D_instance_setup_window(P3D_instance *instance,
 void 
 P3D_object_incref(P3D_object *object) {
   assert(P3DInstanceManager::get_global_ptr()->is_initialized());
-  ACQUIRE_LOCK(_api_lock);
-
-  P3D_OBJECT_INCREF(object);
-  
-  RELEASE_LOCK(_api_lock);
+  if (object != NULL) {
+    ACQUIRE_LOCK(_api_lock);
+    P3D_OBJECT_INCREF(object);
+    RELEASE_LOCK(_api_lock);
+  }
 }
 
 void 
 P3D_object_decref(P3D_object *object) {
   assert(P3DInstanceManager::get_global_ptr()->is_initialized());
-  ACQUIRE_LOCK(_api_lock);
-
-  P3D_OBJECT_DECREF(object);
-  
-  RELEASE_LOCK(_api_lock);
+  if (object != NULL) {
+    ACQUIRE_LOCK(_api_lock);
+    P3D_OBJECT_DECREF(object);
+    RELEASE_LOCK(_api_lock);
+  }
 }
 
 P3D_class_definition *

+ 2 - 1
direct/src/plugin/p3d_plugin.h

@@ -475,7 +475,8 @@ struct _P3D_object {
 #define P3D_OBJECT_DECREF(object) { if (--(object)->_ref_count <= 0) { (object)->_class->_finish((object)); } }
 #define P3D_OBJECT_XDECREF(object) { if ((object) != (P3D_object *)NULL) { P3D_OBJECT_DECREF(object); } }
 
-/* Use these functions for thread-safe variants of the above. */
+/* Use these functions for thread-safe variants of the above.  You may
+   safely pass a NULL pointer into either; it will be ignored. */
 typedef void 
 P3D_object_incref_func(P3D_object *object);
 typedef void