[Bf-blender-cvs] [29e5de3] master: Fix BGE: calling ReleaseInstance on NULL joystick
Campbell Barton
noreply at git.blender.org
Mon Mar 9 06:39:33 CET 2015
Commit: 29e5de3728479d4e38baae1c94b5e4ca8e1da871
Author: Campbell Barton
Date: Mon Mar 9 16:36:35 2015 +1100
Branches: master
https://developer.blender.org/rB29e5de3728479d4e38baae1c94b5e4ca8e1da871
Fix BGE: calling ReleaseInstance on NULL joystick
===================================================================
M source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 70d1aed..d7dd3fe 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1601,17 +1601,22 @@ PyMODINIT_FUNC initGameLogicPythonBinding()
PyObject* joylist = PyList_New(JOYINDEX_MAX);
for (int i=0; i<JOYINDEX_MAX; ++i) {
- SCA_Joystick* joy = SCA_Joystick::GetInstance(i);
+ SCA_Joystick *joy = SCA_Joystick::GetInstance(i);
+ PyObject *item;
+
if (joy && joy->Connected()) {
gp_PythonJoysticks[i] = new SCA_PythonJoystick(joy);
- PyObject* tmp = gp_PythonJoysticks[i]->NewProxy(true);
- Py_INCREF(tmp);
- PyList_SET_ITEM(joylist, i, tmp);
- } else {
- joy->ReleaseInstance();
- Py_INCREF(Py_None);
- PyList_SET_ITEM(joylist, i, Py_None);
+ item = gp_PythonJoysticks[i]->NewProxy(true);
+ }
+ else {
+ if (joy) {
+ joy->ReleaseInstance();
+ }
+ item = Py_None;
}
+
+ Py_INCREF(item);
+ PyList_SET_ITEM(joylist, i, item);
}
PyDict_SetItemString(d, "joysticks", joylist);
More information about the Bf-blender-cvs
mailing list