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:
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 9cd0bdd090a..85f6163c721 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -53,6 +53,7 @@
#include "BLI_path_util.h"
#include "BLI_fileops.h"
+#include "BLI_listbase.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -383,6 +384,7 @@ typedef struct {
static int python_script_exec(bContext *C, const char *fn, struct Text *text,
struct ReportList *reports, const short do_jump)
{
+ Main *bmain_old = CTX_data_main(C);
PyObject *main_mod = NULL;
PyObject *py_dict = NULL, *py_result = NULL;
PyGILState_STATE gilstate;
@@ -461,7 +463,11 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
if (!py_result) {
if (text) {
if (do_jump) {
- python_script_error_jump_text(text);
+ /* ensure text is valid before use, the script may have freed its self */
+ Main *bmain_new = CTX_data_main(C);
+ if ((bmain_old == bmain_new) && (BLI_findindex(&bmain_new->text, text) != -1)) {
+ python_script_error_jump_text(text);
+ }
}
}
BPy_errors_to_report(reports);
@@ -680,11 +686,20 @@ void BPY_modules_load_user(bContext *C)
int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
{
- PyObject *pyctx = (PyObject *)CTX_py_dict_get(C);
- PyObject *item = PyDict_GetItemString(pyctx, member);
+ PyGILState_STATE gilstate;
+ int use_gil = !PYC_INTERPRETER_ACTIVE;
+
+ PyObject *pyctx;
+ PyObject *item;
PointerRNA *ptr = NULL;
int done = FALSE;
+ if (use_gil)
+ gilstate = PyGILState_Ensure();
+
+ pyctx = (PyObject *)CTX_py_dict_get(C);
+ item = PyDict_GetItemString(pyctx, member);
+
if (item == NULL) {
/* pass */
}
@@ -720,7 +735,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
}
else {
- printf("List item not a valid type\n");
+ printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n",
+ member, Py_TYPE(item)->tp_name);
}
}
@@ -740,6 +756,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
}
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
return done;
}