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. :/
This commit is contained in:
@@ -168,7 +168,10 @@ def node_items_iter(context):
|
|||||||
|
|
||||||
# Create an enum list from node class items
|
# Create an enum list from node class items
|
||||||
def node_type_items_cb(self, context):
|
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):
|
class NODE_OT_add_search(NodeAddOperator, Operator):
|
||||||
@@ -177,6 +180,9 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
|
|||||||
bl_label = "Search and Add Node"
|
bl_label = "Search and Add Node"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
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
|
# XXX this should be called 'node_type' but the operator search
|
||||||
# property is hardcoded to 'type' by a hack in bpy_operator_wrap.c ...
|
# property is hardcoded to 'type' by a hack in bpy_operator_wrap.c ...
|
||||||
type = EnumProperty(
|
type = EnumProperty(
|
||||||
|
Reference in New Issue
Block a user