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>2010-01-27 14:18:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-27 14:18:55 +0300
commit7a959059029bcd5abf0a41655d6eb07eb6ef725c (patch)
treeabaff47d733908772dc55e3756f1c358ad307829 /source/creator/creator.c
parent49abcd49f1d54e1929cde5fc01cdda78726bdf2c (diff)
workaround for running python scripts before the contexts values are set.
not happy with this but running python scripts with the -P command line could crash in simple cases (like selecting an object).
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r--source/creator/creator.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 87662e0b7a5..9928ab0be6b 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -707,10 +707,26 @@ int main(int argc, char **argv)
case 'P':
#ifndef DISABLE_PYTHON
- //XXX
- // FOR TESTING ONLY
a++;
- BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
+
+ /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
+ {
+ /* XXX, temp setting the WM is ugly, splash also does this :S */
+ wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindow *prevwin= CTX_wm_window(C);
+
+ if(wm->windows.first) {
+ CTX_wm_window_set(C, wm->windows.first);
+
+ BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
+
+ CTX_wm_window_set(C, prevwin);
+ }
+ else {
+ fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[a]);
+ BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
+ }
+ }
#if 0
a++;
if (a < argc) {