forked from bartvdbraak/blender
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).
This commit is contained in:
parent
49abcd49f1
commit
7a95905902
@ -707,10 +707,26 @@ int main(int argc, char **argv)
|
|||||||
case 'P':
|
case 'P':
|
||||||
|
|
||||||
#ifndef DISABLE_PYTHON
|
#ifndef DISABLE_PYTHON
|
||||||
//XXX
|
|
||||||
// FOR TESTING ONLY
|
|
||||||
a++;
|
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
|
#if 0
|
||||||
a++;
|
a++;
|
||||||
if (a < argc) {
|
if (a < argc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user