Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-03-09 08:36:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-03-09 08:36:35 +0300
commit29e5de3728479d4e38baae1c94b5e4ca8e1da871 (patch)
tree12c082b88fa3b2a80ed65013319f42f6cb48057d
parentc44f489d24a3075e978a0b4b499371fcb3803670 (diff)
Fix BGE: calling ReleaseInstance on NULL joystick
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 70d1aed88a0..d7dd3fe5253 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);