Patch from Charlie:

Cleared the python dictionary at the end of the game engine, should fix some issues,
also reverted the python controller changes, related to this

This should fix the following bugs:
[ #3789 ]
[ #3815 ]

possiblyy fixes:
[ #3834 ]
This commit is contained in:
Erwin Coumans 2006-05-13 23:31:36 +00:00
parent d790049639
commit 4a5826fa83
7 changed files with 21 additions and 6 deletions

@ -311,7 +311,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
initGameLogic(startscene);
PyObject *gameLogic = initGameLogic(startscene);
initGameKeys();
initPythonConstraintBinding();
@ -370,11 +370,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
exitstring = ketsjiengine->GetExitString();
// when exiting the mainloop
dictionaryClearByHand(gameLogic);
exitGamePythonScripting();
ketsjiengine->StopEngine();
networkdevice->Disconnect();
}
if (sceneconverter)
{
delete sceneconverter;

@ -278,7 +278,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
Py_DECREF(excdict);*/
#if 1
#if 0
PyObject *excdict= PyDict_Copy(m_pythondictionary);
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
excdict,
@ -286,13 +286,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
);
PyDict_Clear(excdict);
Py_DECREF(excdict);
#endif
#else
#if 0
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
m_pythondictionary,
m_pythondictionary
);
#endif
if (resultobj)

@ -96,12 +96,14 @@ private:
int m_activecam;
bool m_bFixedTime;
bool m_firstframe;
int m_currentFrame;
double m_frameTime;//discrete timestamp of the 'game logic frame'
double m_clockTime;//current time
double m_previousClockTime;//previous clock time
double m_remainingTime;
static double m_ticrate;

@ -784,6 +784,15 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
return d;
}
void dictionaryClearByHand(PyObject *dict)
{
// Clears the dictionary by hand:
// This prevents, extra references to global variables
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
if(dict) PyDict_Clear(dict);
}
// Python Sandbox code

@ -50,6 +50,8 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
void exitGamePlayerPythonScripting();
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level);
void exitGamePythonScripting();
void dictionaryClearByHand(PyObject *dict);
void PHY_SetActiveScene(class KX_Scene* scene);
#include "MT_Vector3.h"

@ -181,7 +181,7 @@ KX_Scene::~KX_Scene()
if(m_objectlist)
m_objectlist->Release();
if (m_parentlist)
m_parentlist->Release();
@ -210,6 +210,7 @@ KX_Scene::~KX_Scene()
{
delete m_bucketmanager;
}
//Py_DECREF(m_attrlist);
}

@ -528,6 +528,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
if (!SimdFuzzyZero(timeStep))
{
// define this in blender, the stepsize is 30 hertz, 60 hertz works much better
//#define SPLIT_TIMESTEP 1