From 33a94a3996f7610291aaea917aad908e06cf7ccf Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 10 Jul 2009 00:17:30 +0000 Subject: [PATCH] tweaks --- direct/src/plugin/p3dPythonRun.cxx | 1 - direct/src/plugin/p3dSession.cxx | 1 - direct/src/plugin/p3d_plugin.cxx | 20 ++++++++++---------- direct/src/plugin/p3d_plugin.h | 3 ++- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index ffa894fd3f..b851bfe77e 100755 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/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"); diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index f8568fc309..72a447e303 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/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"); diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 4ec61fe6f3..1bdd4c4eec 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/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 * diff --git a/direct/src/plugin/p3d_plugin.h b/direct/src/plugin/p3d_plugin.h index b2562b370e..f2fdbae92b 100644 --- a/direct/src/plugin/p3d_plugin.h +++ b/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