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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-04-19 21:32:14 +0300
committerJorge Bernal <jbernalmartinez@gmail.com>2015-04-19 21:33:08 +0300
commit62f79856e9a14337e32355db8a6add14badb372f (patch)
treeec7f49c893243366a1113c2385d311ace66f93a8 /source/gameengine/Ketsji/KX_Scene.cpp
parent6f0f1dc3be9c88b8d54abce290acee1c948c248b (diff)
BGE : Standardization of callbacks execution.
A new function (RunPythonCallBackList) to call all python functions contained in a python list was developed. This function has: - first argument is the python list of callbacks - second argument is a python list of arguments - third argument is the minimum quantity of arguments - forth argument is the maximum quantity of arguments It improves flexibility and supports *args. Reviewers: moguri, dfelinto, campbellbarton, sybren Reviewed By: campbellbarton, sybren Subscribers: sybren Projects: #game_engine Differential Revision: https://developer.blender.org/D1102
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp27
1 files changed, 4 insertions, 23 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index db4ed58d65f..a3e1d1562c9 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -43,6 +43,7 @@
#include "KX_FontObject.h"
#include "RAS_IPolygonMaterial.h"
#include "ListValue.h"
+#include "KX_PythonCallBack.h"
#include "SCA_LogicManager.h"
#include "SCA_TimeEventManager.h"
//#include "SCA_AlwaysEventManager.h"
@@ -2132,30 +2133,10 @@ void KX_Scene::Render2DFilters(RAS_ICanvas* canvas)
void KX_Scene::RunDrawingCallbacks(PyObject *cb_list)
{
- Py_ssize_t len;
-
- if (cb_list && (len=PyList_GET_SIZE(cb_list)))
- {
- PyObject *args = PyTuple_New(0); // save python creating each call
- PyObject *func;
- PyObject *ret;
-
- // Iterate the list and run the callbacks
- for (Py_ssize_t pos=0; pos < len; pos++)
- {
- func= PyList_GET_ITEM(cb_list, pos);
- ret= PyObject_Call(func, args, NULL);
- if (ret==NULL) {
- PyErr_Print();
- PyErr_Clear();
- }
- else {
- Py_DECREF(ret);
- }
- }
+ if (!cb_list || PyList_GET_SIZE(cb_list) == 0)
+ return;
- Py_DECREF(args);
- }
+ RunPythonCallBackList(cb_list, NULL, 0, 0);
}
//----------------------------------------------------------------------------