From 9e8261a13b696708c3f7f7bac83d5aae8ef43fed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 May 2009 05:57:08 +0000 Subject: Disable importing module python controller scripts at conversion time because it can run BGE functions and crash since the internal state isnt setup yet. face-select mode wasnt working when used with projection paint. --- source/blender/src/drawview.c | 2 +- source/gameengine/Converter/KX_ConvertControllers.cpp | 9 +++++++-- source/gameengine/GameLogic/SCA_PythonController.cpp | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 203c9869022..d6184f42410 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -977,7 +977,7 @@ void backdrawview3d(int test) int m; #endif - if( G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT ); + if( G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST)); else if ((G.f & G_TEXTUREPAINT) && G.scene->toolsettings && (G.scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); else if(G.obedit && G.vd->drawtype>OB_WIRE && (G.vd->flag & V3D_ZBUF_SELECT)); else { diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 79664ca4622..856f3f79588 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -216,8 +216,13 @@ void BL_ConvertControllers( * gives more pradictable performance for larger scripts */ if(pyctrl->m_mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) pyctrl->Compile(); - else - pyctrl->Import(); + else { + /* We cant do this because importing runs the script which could end up accessing + * internal BGE functions, this is unstable while we're converting the scene. + * This is a pitty because its useful to see errors at startup but cant help it */ + + // pyctrl->Import(); + } } //done with gamecontroller diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index bf4c2475a64..0e78e03d5af 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -164,6 +164,11 @@ static const char* sPyGetCurrentController__doc__; /* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self) { + if(m_sCurrentController==NULL) + { + PyErr_SetString(PyExc_SystemError, "GameLogic.getCurrentController(), this function is being run outside the python controllers context, or blenders internal state is corrupt."); + return NULL; + } return m_sCurrentController->GetProxy(); } -- cgit v1.2.3