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
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_interface.c4
-rw-r--r--source/blender/python/intern/bpy_rna.c18
-rw-r--r--source/blender/python/intern/bpy_rna.h2
3 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index d20f2a23664..d0e321ade06 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -330,6 +330,8 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
return 0;
}
+ bpy_set_immediate_register(1);
+
bpy_context_set(C, &gilstate);
if (text) {
@@ -395,6 +397,8 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
bpy_context_clear(C, &gilstate);
+ bpy_set_immediate_register(0);
+
return py_result ? 1:0;
}
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 8be9cc4cdae..8fc7fc2b342 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4175,9 +4175,11 @@ static PyObject *pyrna_basetype_getattro( BPy_BaseTypeRNA *self, PyObject *pynam
static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self);
static PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class);
static PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class);
+static PyObject *pyrna_register_immediate(PyObject *self);
static struct PyMethodDef pyrna_basetype_methods[] = {
{"__dir__", (PyCFunction)pyrna_basetype_dir, METH_NOARGS, ""},
+ {"immediate", (PyCFunction)pyrna_register_immediate, METH_NOARGS, ""},
{"register", (PyCFunction)pyrna_basetype_register, METH_O, ""},
{"unregister", (PyCFunction)pyrna_basetype_unregister, METH_O, ""},
{NULL, NULL, 0, NULL}
@@ -4769,6 +4771,22 @@ void pyrna_free_types(void)
}
+static int IMMEDIATE = 0;
+
+void bpy_set_immediate_register(int value)
+{
+ IMMEDIATE = value;
+}
+
+static PyObject *pyrna_register_immediate(PyObject *self)
+{
+ if (IMMEDIATE) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+}
+
/* Note! MemLeak XXX
*
* There is currently a bug where moving registering a python class does
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index bd9838a76d4..32f2cd477d6 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -86,6 +86,8 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_
int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix);
+void bpy_set_immediate_register(int value);
+
int pyrna_deferred_register_props(struct StructRNA *srna, PyObject *class_dict);
/* called before stopping python */