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:
authorWillian Padovani Germano <wpgermano@gmail.com>2004-11-09 17:07:25 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2004-11-09 17:07:25 +0300
commitc16e5dad1cd03f3b3a3a72d7e2dc556096a3f969 (patch)
treef43599acb6896afe2e2744833bf795dc14db1ea1
parent1197c4842afea438356aaba17f4380f31014be12 (diff)
BPython:
- Small doc update in a script; - Fixed bug #1742: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1742&group_id=9 It was an internal error in bpython. I was using G.main->script.last to find the currently running (if any) script, but this isn't reliable, we must check each open script to find out if one of them has the SCRIPT_RUNNING bitflag set. Thanks intrr for reporting and blendix for pointing how to reproduce the bug. From my tests it should be working fine now.
-rw-r--r--release/scripts/ac3d_export.py11
-rw-r--r--source/blender/python/BPY_interface.c14
-rw-r--r--source/blender/python/api2_2x/Draw.c44
3 files changed, 41 insertions, 28 deletions
diff --git a/release/scripts/ac3d_export.py b/release/scripts/ac3d_export.py
index b3fb3008947..2f44c0910c4 100644
--- a/release/scripts/ac3d_export.py
+++ b/release/scripts/ac3d_export.py
@@ -18,7 +18,7 @@ __version__ = "2.34 09/20/04"
__bpydoc__ = """\
This script exports Blender meshes to AC3D's .ac file format.
-AC3D is a simple and affordable commercial 3d modeller also built with OpenGL.
+AC3D is a simple commercial 3d modeller also built with OpenGL.
The .ac file format is an easy to parse text format well supported,
for example, by the PLib 3d gaming library (AC3D v3.x).
@@ -26,18 +26,19 @@ Supported:<br>
UV-textured meshes with hierarchy (grouping) information.
Missing:<br>
- Support for AC3D 4's crease tag (simple, will be added soon).
+ Support for AC3D 4's crease tag (simple, will be added as option for
+the next version of this exporter).
Known issues:<br>
Models textured with more than one image do not work -- for the
moment you can separate them in Blender such that each mesh only has one
image assigned (also see notes below);<br>
The exporter is slow for large meshes -- faster code was written for the
-TuxKart (http://tuxkart.sf.net) game exporter and will be integrated on a
-future version of this exporter.
+TuxKart (http://tuxkart.sf.net, wiki at http://netpanzer.berlios.de/tuxkart)
+game exporter and will be integrated on a future version of this exporter.
Notes:<br>
- There is a version of this script by <fix this> that accepts meshes with
+ There is a version of this script, by Ingo Ruhnke, that accepts meshes with
more than one texture image assigned, check TuxKart's wiki.
"""
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 6184b06baa2..1fd217656d9 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -604,7 +604,8 @@ int BPY_menu_do_python( short menutype, int event )
char *buffer, *s;
char filestr[FILE_MAXDIR + FILE_MAXFILE];
char dirname[FILE_MAXDIR];
- Script *script = G.main->script.first;
+ char scriptname[21];
+ Script *script = NULL;
int len;
pym = BPyMenu_GetEntry( menutype, ( short ) event );
@@ -660,8 +661,17 @@ int BPY_menu_do_python( short menutype, int event )
return 0;
}
+ BLI_strncpy(scriptname, pym->name, 21);
+ len = strlen(scriptname) - 1;
+ /* by convention, scripts that open the file browser or have submenus
+ * display '...'. Here we remove them from the datablock name */
+ while ((len > 0) && scriptname[len] == '.') {
+ scriptname[len] = '\0';
+ len--;
+ }
+
/* Create a new script structure and initialize it: */
- script = alloc_libblock( &G.main->script, ID_SCRIPT, pym->name );
+ script = alloc_libblock( &G.main->script, ID_SCRIPT, scriptname );
if( !script ) {
printf( "couldn't allocate memory for Script struct!" );
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 24d45fcc993..bd01c871978 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -602,30 +602,33 @@ static PyObject *Method_Register( PyObject * self, PyObject * args )
sc = curarea->spacedata.first;
- /* this is a little confusing: we need to know which script is being executed
- * now, so we can preserve its namespace from being deleted.
- * There are two possibilities:
- * a) One new script was created and the interpreter still hasn't returned
- * from executing it.
- * b) Any number of scripts were executed but left registered callbacks and
- * so were not deleted yet. */
-
- /* To find out if we're dealing with a) or b), we start with the last
- * created one: */
- script = G.main->script.last;
+ /* There are two kinds of scripts:
+ * a) those that simply run, finish and return control to Blender;
+ * b) those that do like 'a)' above but leave callbacks for drawing,
+ * events and button events, with this Method_Register (Draw.Register
+ * in Python). These callbacks are called by scriptspaces (Scripts windows).
+ *
+ * We need to flag scripts that leave callbacks so their namespaces are
+ * not deleted when they 'finish' execution, because the callbacks will
+ * still need the namespace.
+ */
- if( !script ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Draw.Register: couldn't get pointer to script struct" );
+ /* Let's see if this is a new script */
+ script = G.main->script.first;
+ while (script) {
+ if (script->flags & SCRIPT_RUNNING) break;
+ script = script->id.next;
}
- /* if the flag SCRIPT_RUNNING is set, this script is case a): */
- if( !( script->flags & SCRIPT_RUNNING ) ) {
- script = sc->script;
+ if( !script ) {
+ /* not new, it's a left callback calling Register again */
+ script = sc->script;
+ if( !script ) {
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Draw.Register: couldn't get pointer to script struct" );
+ }
}
- /* otherwise it's case b) and the script we want is here: */
- else
- sc->script = script;
+ else sc->script = script;
/* Now we have the right script and can set a lock so its namespace can't be
* deleted for as long as we need it */
@@ -660,7 +663,6 @@ static PyObject *Method_Redraw( PyObject * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument (or nothing)" );
- /* XXX shouldn't we redraw all spacescript wins with this script on ? */
if( after )
addafterqueue( curarea->win, REDRAW, 1 );
else