[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56191] trunk/blender/release/scripts/ startup/bl_operators/node.py: Fix for add nodes search box showing nasty " UUUUUUUU"-like entries with some python builds...

Bastien Montagne montagne29 at wanadoo.fr
Sun Apr 21 15:51:51 CEST 2013


Revision: 56191
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56191
Author:   mont29
Date:     2013-04-21 13:51:51 +0000 (Sun, 21 Apr 2013)
Log Message:
-----------
Fix for add nodes search box showing nasty "UUUUUUUU"-like entries with some python builds...

Workaround for an issue with python: strings generated by py scripts should also exist in python as long as they are used in C. Else C code may access freed memory.

Simply store the generated list of items in the class, for now. :/

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/node.py

Modified: trunk/blender/release/scripts/startup/bl_operators/node.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/node.py	2013-04-21 13:29:24 UTC (rev 56190)
+++ trunk/blender/release/scripts/startup/bl_operators/node.py	2013-04-21 13:51:51 UTC (rev 56191)
@@ -168,7 +168,10 @@
 
 # Create an enum list from node class items
 def node_type_items_cb(self, context):
-    return [(str(index), item[1], item[2]) for index, item in enumerate(node_items_iter(context))]
+    # XXX Python has to keep a ref to those strings, else they may be freed :(
+    NODE_OT_add_search._enum_str_store = [(str(index), item[1], item[2])
+                                          for index, item in enumerate(node_items_iter(context))]
+    return NODE_OT_add_search._enum_str_store
 
 
 class NODE_OT_add_search(NodeAddOperator, Operator):
@@ -177,6 +180,9 @@
     bl_label = "Search and Add Node"
     bl_options = {'REGISTER', 'UNDO'}
 
+    # XXX Python has to keep a ref to the data (strings) generated by enum's callback, else they may be freed :(
+    _enum_str_store = []
+
     # XXX this should be called 'node_type' but the operator search
     # property is hardcoded to 'type' by a hack in bpy_operator_wrap.c ...
     type = EnumProperty(




More information about the Bf-blender-cvs mailing list