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.
This commit is contained in:
@@ -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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -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!" );
|
||||
|
||||
@@ -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. */
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/* To find out if we're dealing with a) or b), we start with the last
|
||||
* created one: */
|
||||
script = G.main->script.last;
|
||||
/* 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( !script ) {
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"Draw.Register: couldn't get pointer to script struct" );
|
||||
/* 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" );
|
||||
}
|
||||
}
|
||||
|
||||
/* if the flag SCRIPT_RUNNING is set, this script is case a): */
|
||||
if( !( script->flags & SCRIPT_RUNNING ) ) {
|
||||
script = sc->script;
|
||||
}
|
||||
/* 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
|
||||
|
||||
Reference in New Issue
Block a user