فهرست منبع

don't unpack to python obejct if no method to receive it

David Rose 21 سال پیش
والد
کامیت
263ebe9ca8
1فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 11 3
      direct/src/dcparser/dcField.cxx

+ 11 - 3
direct/src/dcparser/dcField.cxx

@@ -464,10 +464,18 @@ unpack_args(DCPacker &packer) const {
 ////////////////////////////////////////////////////////////////////
 void DCField::
 receive_update(DCPacker &packer, PyObject *distobj) const {
-  PyObject *args = unpack_args(packer);
+  if (!PyObject_HasAttrString(distobj, (char *)_name.c_str())) {
+    // If there's no Python method to receive this message, don't
+    // bother unpacking it to a Python tuple--just skip past the
+    // message.
+    packer.unpack_skip();
 
-  if (args != (PyObject *)NULL) {
-    if (PyObject_HasAttrString(distobj, (char *)_name.c_str())) {
+  } else {
+    // Otherwise, get a Python tuple from the args and call the Python
+    // method.
+    PyObject *args = unpack_args(packer);
+
+    if (args != (PyObject *)NULL) {
       PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str());
       nassertv(func != (PyObject *)NULL);