浏览代码

pgraph: Fix bug passing non-tuple sequence to shader input

rdb 4 年之前
父节点
当前提交
f20d859fe2
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 1 1
      panda/src/pgraph/shaderInput_ext.cxx
  2. 5 0
      tests/pgraph/test_shaderinput.py

+ 1 - 1
panda/src/pgraph/shaderInput_ext.cxx

@@ -282,7 +282,7 @@ __init__(CPT_InternalName name, PyObject *value, int priority) {
       return;
       return;
     }
     }
 
 
-    Py_ssize_t num_items = PySequence_Fast_GET_SIZE(value);
+    Py_ssize_t num_items = PySequence_Fast_GET_SIZE(fast);
     if (num_items <= 0) {
     if (num_items <= 0) {
       // We can't determine the type of a list of size 0.
       // We can't determine the type of a list of size 0.
       _this->_type = ShaderInput::M_numeric;
       _this->_type = ShaderInput::M_numeric;

+ 5 - 0
tests/pgraph/test_shaderinput.py

@@ -1,4 +1,9 @@
 from panda3d.core import ShaderInput, Vec4
 from panda3d.core import ShaderInput, Vec4
+from array import array
+
+
+def test_shaderinput_construct_sequence_int():
+    i = ShaderInput('test', array('I', [1, 2, 3, 4]))
 
 
 
 
 def test_shaderinput_vector_compare():
 def test_shaderinput_vector_compare():