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
This commit is contained in:
Campbell Barton 2008-10-03 04:41:02 +00:00
parent 5f7bd14073
commit 365282e5c8

@ -1505,10 +1505,17 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length)
if (gameLogic) { if (gameLogic) {
PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length);
if (pyGlobalDict) { 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(gameLogic);
Py_DECREF(pyGlobalDict);
return 1; return 1;
} else { } else {
Py_DECREF(gameLogic); Py_DECREF(gameLogic);