diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2012-12-22 09:38:32 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2012-12-22 09:38:32 +0400 |
commit | 84966c3d0ae2d39fa4e691ed0131d8b94f8785e4 (patch) | |
tree | 96f1fbaac1e4b2f151c7726c90b8491a718666c1 /source/gameengine/Ketsji/KX_Scene.cpp | |
parent | 8062bcd16f9e91d76dbd074f32b889ce2e0cba84 (diff) |
BGE: Committing async LibLoad from Swiss. This does the lib loading in a separate thread to keep the BGE from freezing. Here is an example from the docs:
# Print a message when an async LibLoad is done
import bge
def finished_cb(status):
print("Library (%s) loaded in %.2fms." % (status.libraryName, status.timeTaken))
bge.logic.LibLoad('myblend.blend', 'Scene', async=True).onFinish = finished_cb
LibLoad() now returns a KX_LibLoadStatus object for information on the library loading. LibNew() and LibFree() are unaffected by this commit. In other words, the async option only works for LibLoad(). Furthermore it only works for Scenes, not Actions or Meshes.
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 72be5f57b95..d298d1b4815 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -227,9 +227,13 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, } #ifdef WITH_PYTHON + // We might be running in a separate thread (async libload) so + // try and grab the GIL to avoid issues + PyGILState_STATE gstate = PyGILState_Ensure(); m_attr_dict = PyDict_New(); /* new ref */ m_draw_call_pre = NULL; m_draw_call_post = NULL; + PyGILState_Release(gstate); #endif } |