Revision: 16624
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16624
Author:   aligorith
Date:     2008-09-20 12:10:50 +0200 (Sat, 20 Sep 2008)

Log Message:
-----------
Patch #17654: Fix for Scene.Get with input >20 chars
Patch by Darryl Pogue (paradox).

Blender cuts off datablock names at 20 chars, which causes issues if you're 
trying to access Scenes with a string longer
than 20 chars.

Ex.

s = 'GuildPub-Writers_GLOBAL'
Blender.Scene.New(s) #This creates the scene "GuildPub-Writers_GLOB"
Blender.Scene.Get(s) #This throws an error: the name and the string don't match

This patch cuts down the input of Scene.Get() to the 20 char limits, thus 
making the the above example return the correct
scene.

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Scene.c

Modified: trunk/blender/source/blender/python/api2_2x/Scene.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Scene.c 2008-09-20 10:02:13 UTC 
(rev 16623)
+++ trunk/blender/source/blender/python/api2_2x/Scene.c 2008-09-20 10:10:50 UTC 
(rev 16624)
@@ -635,16 +635,19 @@
 /*-----------------------Scene.Get()------------------------------------*/
 static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
 {
-       char *name = NULL;
+       char *tname = NULL, name[22];
        Scene *scene_iter;
 
-       if( !PyArg_ParseTuple( args, "|s", &name ) )
+       if( !PyArg_ParseTuple( args, "|s", &tname ) )
                return ( EXPP_ReturnPyObjError( PyExc_TypeError,
                                                "expected string argument (or 
nothing)" ) );
 
+       strncpy(name, tname, 21);
+       if( strlen(tname) >= 21 ) name[21]= 0;
+       
        scene_iter = G.main->scene.first;
 
-       if( name ) {            /* (name) - Search scene by name */
+       if( tname ) {           /* (name) - Search scene by name */
 
                PyObject *wanted_scene = NULL;
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to