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>2011-02-01 05:54:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-01 05:54:29 +0300
commitb17bbf9d9548a608d865a25c629e142f12ce762a (patch)
treeeeba3478ada3f0d10c20774e57b2fe1e9a18c6f1
parent339d3bf05f6b34064ed9e0c5016b315e0a1e5cf9 (diff)
fix for 2 segfaults running in background mode.
- operators which reload G.main would crash blender if called from python and then accessed bpy.data.* - WM_read_homefile_exec was setting the contexts Scene to NULL as a signal for the event system, this didnt work in background mode, crashing when property update functions expected scene to be set.
-rw-r--r--source/blender/python/intern/bpy_operator.c6
-rw-r--r--source/blender/python/intern/bpy_rna.c2
-rw-r--r--source/blender/python/intern/bpy_rna.h2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c4
5 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 2130dd60f12..70aa46c1302 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -231,6 +231,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
+ /* when calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer is freed by clear_globals(),
+ * further access will crash blender. setting context is not needed in this case, only calling because this
+ * function corrects bpy.data (internal Main pointer) */
+ BPY_modules_update(C);
+
+
/* return operator_ret as a bpy enum */
return pyrna_enum_bitfield_to_py(operator_return_items, operator_ret);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 41aa0661fd5..65e0ec5a507 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5316,8 +5316,6 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
return 0;
}
-extern void BPY_modules_update(bContext *C); //XXX temp solution
-
/* TODO - multiple return values like with rna functions */
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
{
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 854f077abed..31954eb6828 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -110,4 +110,6 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
int pyrna_write_check(void);
+void BPY_modules_update(struct bContext *C); //XXX temp solution
+
#endif
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 80b88309883..644320b0566 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -429,9 +429,13 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory)
BPY_modules_load_user(C);
}
#endif
-
+
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
- CTX_wm_window_set(C, NULL); /* exits queues */
+
+ /* in background mode the scene will stay NULL */
+ if(!G.background) {
+ CTX_wm_window_set(C, NULL); /* exits queues */
+ }
return TRUE;
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5aa2f6c1c50..1b602b167c7 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1350,7 +1350,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
ot->invoke= WM_operator_confirm;
ot->exec= WM_read_homefile_exec;
- ot->poll= WM_operator_winactive;
+ /* ommit poll to run in background mode */
}
static void WM_OT_read_factory_settings(wmOperatorType *ot)
@@ -1361,7 +1361,7 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot)
ot->invoke= WM_operator_confirm;
ot->exec= WM_read_homefile_exec;
- ot->poll= WM_operator_winactive;
+ /* ommit poll to run in background mode */
}
/* *************** open file **************** */