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:
authorCampbell Barton <ideasman42@gmail.com>2020-10-15 10:12:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-15 11:00:16 +0300
commit5531697f6d4a27137dd91996ee80d452b7147a02 (patch)
tree8c024bc8acac8387a22cc7bfa43ed4d1a5691321 /source/blender/python/intern/bpy_interface.c
parent1cc3abca701775e0ddb0756a262df99b8e7a0276 (diff)
Cleanup: remove duplicate context variable (__py_context)
The context was stored both in __py_context & bpy_context_module. This avoids duplicate functions to update them too.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index f64332d94cc..468abd7b575 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -111,8 +111,8 @@ void BPY_context_update(bContext *C)
return;
}
- BPy_SetContext(C);
- BPY_modules_update(C); /* can give really bad results if this isn't here */
+ BPY_context_set(C);
+ BPY_modules_update(); /* can give really bad results if this isn't here */
}
void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
@@ -155,7 +155,7 @@ void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate)
/* XXX - Calling classes currently wont store the context :\,
* cant set NULL because of this. but this is very flakey still. */
#if 0
- BPy_SetContext(NULL);
+ BPY_context_set(NULL);
#endif
#ifdef TIME_PY_RUN
@@ -224,7 +224,10 @@ void BPY_text_free_code(Text *text)
}
}
-void BPY_modules_update(bContext *C)
+/**
+ * Needed so the #Main pointer in `bpy.data` doesn't become out of date.
+ */
+void BPY_modules_update(void)
{
#if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
@@ -234,14 +237,16 @@ void BPY_modules_update(bContext *C)
/* refreshes the main struct */
BPY_update_rna_module();
- if (bpy_context_module) {
- bpy_context_module->ptr.data = (void *)C;
- }
+}
+
+bContext *BPy_GetContext(void)
+{
+ return bpy_context_module->ptr.data;
}
void BPY_context_set(bContext *C)
{
- BPy_SetContext(C);
+ bpy_context_module->ptr.data = (void *)C;
}
#ifdef WITH_FLUID
@@ -295,7 +300,7 @@ static struct _inittab bpy_internal_modules[] = {
};
/* call BPY_context_set first */
-void BPY_python_start(int argc, const char **argv)
+void BPY_python_start(bContext *C, int argc, const char **argv)
{
#ifndef WITH_PYTHON_MODULE
PyThreadState *py_tstate = NULL;
@@ -387,7 +392,7 @@ void BPY_python_start(int argc, const char **argv)
#endif
/* bpy.* and lets us import it */
- BPy_init_modules();
+ BPy_init_modules(C);
pyrna_alloc_types();