diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-03-09 08:36:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-03-09 08:36:35 +0300 |
commit | 29e5de3728479d4e38baae1c94b5e4ca8e1da871 (patch) | |
tree | 12c082b88fa3b2a80ed65013319f42f6cb48057d /source/gameengine | |
parent | c44f489d24a3075e978a0b4b499371fcb3803670 (diff) |
Fix BGE: calling ReleaseInstance on NULL joystick
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 21 |
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); |