Revert "BGE: Fix T44557 GameLogic module memory leak."

This reverts commit cd24871706.
The commit re-introduced problems with starting the game engine
multiple times in the same run of Blender.
This commit is contained in:
Sybren A. Stüvel 2015-08-26 11:11:40 +02:00
parent 3699ab1843
commit 77ce7eb541
Notes: blender-bot 2023-02-14 09:10:54 +01:00
Referenced by issue #44557, BGE leaves references in memory after quitting
1 changed files with 15 additions and 4 deletions

View File

@ -588,11 +588,22 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
PyDict_Clear(PyModule_GetDict(gameLogic));
PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict);
//PyDict_Clear(PyModule_GetDict(gameLogic));
// Keep original items, means python plugins will autocomplete members
PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic));
const Py_ssize_t numitems= PyList_GET_SIZE(gameLogic_keys_new);
Py_ssize_t listIndex;
for (listIndex=0; listIndex < numitems; listIndex++) {
PyObject *item = PyList_GET_ITEM(gameLogic_keys_new, listIndex);
if (!PySequence_Contains(gameLogic_keys, item)) {
PyDict_DelItem( PyModule_GetDict(gameLogic), item);
}
}
Py_DECREF(gameLogic_keys_new);
gameLogic_keys_new = NULL;
#endif
ketsjiengine->StopEngine();
#ifdef WITH_PYTHON
exitGamePythonScripting();