Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2014-04-16 12:15:40 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-04-16 12:15:40 +0400
commitd050577176366617bcfdc86f9dd659143e024648 (patch)
treec49f1e246af987551db43b34e445c51850fe62b2 /source/gameengine/Converter/KX_ConvertControllers.cpp
parent4769b44bdda7999bb69de9602f10dced3de2affe (diff)
Fix T39445: Async LibLoad Crash
There was some deadlock due to trying manage Python's GIL. Instead of continuing to fight with it, anything needing to call into Python while conversion during lib loading is just delayed until it can be done in the main thread.
Diffstat (limited to 'source/gameengine/Converter/KX_ConvertControllers.cpp')
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
index 5d3d0f33bec..ab5f1611cb9 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ b/source/gameengine/Converter/KX_ConvertControllers.cpp
@@ -94,7 +94,8 @@ void BL_ConvertControllers(
SCA_LogicManager* logicmgr,
int activeLayerBitInfo,
bool isInActiveLayer,
- KX_BlenderSceneConverter* converter
+ KX_BlenderSceneConverter* converter,
+ bool libloading
) {
int uniqueint=0;
int count = 0;
@@ -157,8 +158,9 @@ void BL_ConvertControllers(
SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
gamecontroller = pyctrl;
#ifdef WITH_PYTHON
- PyGILState_STATE gstate = PyGILState_Ensure();
- pyctrl->SetNamespace(converter->GetPyNamespace());
+ // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
+ if (!libloading)
+ pyctrl->SetNamespace(converter->GetPyNamespace());
if (pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
if (pycont->text)
@@ -185,8 +187,6 @@ void BL_ConvertControllers(
pyctrl->SetDebug(true);
}
}
-
- PyGILState_Release(gstate);
#endif // WITH_PYTHON
break;
@@ -219,8 +219,8 @@ void BL_ConvertControllers(
converter->RegisterGameController(gamecontroller, bcontr);
#ifdef WITH_PYTHON
- PyGILState_STATE gstate = PyGILState_Ensure();
- if (bcontr->type==CONT_PYTHON) {
+ // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
+ if (!libloading && bcontr->type==CONT_PYTHON) {
SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller);
/* not strictly needed but gives syntax errors early on and
* gives more predictable performance for larger scripts */
@@ -235,7 +235,6 @@ void BL_ConvertControllers(
}
}
- PyGILState_Release(gstate);
#endif // WITH_PYTHON
//done with gamecontroller