Browse Source

Fix exception when trying to pickle NodePathCollection objects

rdb 9 years ago
parent
commit
4526de8f7a
2 changed files with 8 additions and 4 deletions
  1. 1 0
      doc/ReleaseNotes
  2. 7 4
      panda/src/pgraph/nodePathCollection_ext.cxx

+ 1 - 0
doc/ReleaseNotes

@@ -45,6 +45,7 @@ This issue fixes several bugs that were still found in 1.9.2.
 * Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons
 * Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons
 * Add keyword argument support to make() methods such as Shader.make()
 * Add keyword argument support to make() methods such as Shader.make()
 * Fix compilation errors with Bullet 2.84
 * Fix compilation errors with Bullet 2.84
+* Fix exception when trying to pickle NodePathCollection objects
 
 
 ------------------------  RELEASE 1.9.2  ------------------------
 ------------------------  RELEASE 1.9.2  ------------------------
 
 

+ 7 - 4
panda/src/pgraph/nodePathCollection_ext.cxx

@@ -84,16 +84,19 @@ __reduce__(PyObject *self) const {
   // (e.g. this), and the arguments necessary to reconstruct this
   // (e.g. this), and the arguments necessary to reconstruct this
   // object.
   // object.
 
 
-  PyObject *this_class = PyObject_Type(self);
+  PyObject *this_class = (PyObject *)self->ob_type;
   if (this_class == NULL) {
   if (this_class == NULL) {
     return NULL;
     return NULL;
   }
   }
 
 
+  PyObject *self_iter = PyObject_GetIter(self);
+  if (self_iter == NULL) {
+    return NULL;
+  }
+
   // Since a NodePathCollection is itself an iterator, we can simply
   // Since a NodePathCollection is itself an iterator, we can simply
   // pass it as the fourth tuple component.
   // pass it as the fourth tuple component.
-  PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self);
-  Py_DECREF(this_class);
-  return result;
+  return Py_BuildValue("(O()ON)", this_class, Py_None, self_iter);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////