Crash with GeListHead and TreeViewFunctions SetName()

  • Hello,

    I noticed that when using a GeListHead for storing custom BaseList2D items leads to a crash when TreeViewFunctions' SetName is called.
    Is this a known bug/behavior?
    If not, what did I do wrong? ;)

    Here's a minimal example. Try to rename any ListItem with Double-Click -> Freeze.
    On R21 I did some more debugging and it turned out that obj in SetName() is of type long.

    import c4d
    from c4d import gui
    from c4d import plugins
    PLUGIN_ID = 1000001  # Test plugin id
    PLUGIN_ID_ND = 1000002  # Test plugin id
    class ListItem(plugins.NodeData):
        def Init(self, node):
            # do stuff here
            return True
    class Tvf(gui.TreeViewFunctions):
        def GetFirst(self, root, userdata):
            if not root:
                return None
            return root.GetFirst()
        def GetNext(self, root, userdata, obj):
            return obj.GetNext()
        def GetName(self, root, userdata, obj):
            return obj.GetName()
        def SetName(self, root, userdata, obj, str):
    class TestDialog(gui.GeDialog):
        def __init__(self):
            self.items = c4d.GeListHead()
            self.treegui = None
            self.tvf = Tvf()
        def add_item(self):
            item = c4d.BaseList2D(PLUGIN_ID_ND)
        def CreateLayout(self):
            settings = c4d.BaseContainer()
            settings.SetBool(c4d.TREEVIEW_HAS_HEADER, True)
            self.treegui = self.AddCustomGui(0, c4d.CUSTOMGUI_TREEVIEW, "",
                                             c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT,
            return True
        def InitValues(self):
            for x in range(5):
            layout_bc = c4d.BaseContainer()
            layout_bc.SetInt32(0, c4d.LV_TREE)
            self.treegui.SetLayout(1, layout_bc)
            self.treegui.SetHeaderText(0, "Name")
            self.treegui.SetRoot(self.items, self.tvf, None)
            return True
    class TestCommand(plugins.CommandData):
        def __init__(self):
            self.dlg = None
        def Register(self):
            return plugins.RegisterCommandPlugin(PLUGIN_ID, "Test-Plugin", 0, None, None, self)
        def Execute(self, doc):
            if self.dlg is None:
                self.dlg = TestDialog()
            return self.dlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaulth=400, defaultw=400)
        def RestoreLayout(self, sec_ref):
            if self.dlg is None:
                self.dlg = TestDialog()
            return self.dlg.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
    if __name__ == '__main__':
        plugins.RegisterNodePlugin(PLUGIN_ID_ND, "ListItem", c4d.PLUGINFLAG_HIDE, ListItem, None)

  • Hi @mp5gosu unfortunately this is a bug, I'm still digging it so thanks for the report :)

    I will take you informed if I found a workaround.