diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-10-03 08:41:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-10-03 08:41:02 +0400 |
commit | 365282e5c8c382a26f5111a8ae9921a989235e66 (patch) | |
tree | bf62654b18a48523ff25e84d7ba3fb616297ac20 /source/gameengine/Ketsji/KX_PythonInit.cpp | |
parent | 5f7bd14073082f8c31e8540c99471e94ea11529c (diff) |
error with GameLogic.globalDict loading. It would replace the dictionary rather then updating it.
This meant the BGE would load in an old dictonary replacing the loaded dict, loosing settings.
was also missing a decref for marshal data
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index fc836234e2b..53b141a9bfe 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1505,10 +1505,17 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) if (gameLogic) { PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); - if (pyGlobalDict) { - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + PyObject* pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module. + if (pyGlobalDict_orig) { + PyDict_Clear(pyGlobalDict_orig); + PyDict_Update(pyGlobalDict_orig, pyGlobalDict); + } else { + /* this should not happen, but cant find the original globalDict, just assign it then */ + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + } Py_DECREF(gameLogic); + Py_DECREF(pyGlobalDict); return 1; } else { Py_DECREF(gameLogic); |