[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37360] trunk/blender: - remove window poll from WM_OT_open_mainfile so files can be loaded in background mode (move the check to invoke)

Campbell Barton ideasman42 at gmail.com
Fri Jun 10 09:43:34 CEST 2011


Revision: 37360
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37360
Author:   campbellbarton
Date:     2011-06-10 07:43:33 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
- remove window poll from WM_OT_open_mainfile so files can be loaded in background mode (move the check to invoke)
- remove a console workaround for a bug in python 3.1.2's io.StringIO().

Modified Paths:
--------------
    trunk/blender/build_files/cmake/example_scripts/cmake_linux_install.sh
    trunk/blender/release/scripts/modules/console_python.py
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/build_files/cmake/example_scripts/cmake_linux_install.sh
===================================================================
--- trunk/blender/build_files/cmake/example_scripts/cmake_linux_install.sh	2011-06-10 07:27:30 UTC (rev 37359)
+++ trunk/blender/build_files/cmake/example_scripts/cmake_linux_install.sh	2011-06-10 07:43:33 UTC (rev 37360)
@@ -17,7 +17,7 @@
 
 # cmake without copying files for fast rebuilds
 # the files from svn will be used in place
-cmake ../blender -DWITH_INSTALL:BOOL=FALSE
+cmake ../blender
 
 # make blender, will take some time
 make

Modified: trunk/blender/release/scripts/modules/console_python.py
===================================================================
--- trunk/blender/release/scripts/modules/console_python.py	2011-06-10 07:27:30 UTC (rev 37359)
+++ trunk/blender/release/scripts/modules/console_python.py	2011-06-10 07:43:33 UTC (rev 37360)
@@ -79,12 +79,6 @@
 
     if console_data:
         console, stdout, stderr = console_data
-
-        # XXX, bug in python 3.1.2 ? (worked in 3.1.1)
-        # seems there is no way to clear StringIO objects for writing, have to make new ones each time.
-        import io
-        stdout = io.StringIO()
-        stderr = io.StringIO()
     else:
         if _BPY_MAIN_OWN:
             import types

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-06-10 07:27:30 UTC (rev 37359)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-06-10 07:43:33 UTC (rev 37360)
@@ -1485,6 +1485,14 @@
 {
 	const char *openname= G.main->name;
 
+	if(CTX_wm_window(C) == NULL) {
+		/* in rare cases this could happen, when trying to invoke in background
+		 * mode on load for example. Don't use poll for this because exec()
+		 * can still run without a window */
+		BKE_report(op->reports, RPT_ERROR, "Context window not set");
+		return OPERATOR_CANCELLED;
+	}
+
 	/* if possible, get the name of the most recently used .blend file */
 	if (G.recent_files.first) {
 		struct RecentFile *recent = G.recent_files.first;
@@ -1535,7 +1543,7 @@
 	
 	ot->invoke= wm_open_mainfile_invoke;
 	ot->exec= wm_open_mainfile_exec;
-	ot->poll= WM_operator_winactive;
+	/* ommit window poll so this can work in background mode */
 	
 	WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 
@@ -1954,7 +1962,7 @@
 	ot->invoke= wm_save_mainfile_invoke;
 	ot->exec= wm_save_as_mainfile_exec;
 	ot->check= blend_save_check;
-	ot->poll= NULL;
+	/* ommit window poll so this can work in background mode */
 	
 	WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
 	RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");




More information about the Bf-blender-cvs mailing list