Revision: 26330
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26330
Author: campbellbarton
Date: 2010-01-27 12:18:55 +0100 (Wed, 27 Jan 2010)
Log Message:
-----------
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).
Modified Paths:
--------------
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2010-01-27 10:54:11 UTC (rev
26329)
+++ trunk/blender/source/creator/creator.c 2010-01-27 11:18:55 UTC (rev
26330)
@@ -707,10 +707,26 @@
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) {
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs