Page MenuHome

Crash on undo changes in template_list
Open, Confirmed, MediumPublic

Description

Sorry for the translation.

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: GeForce GTX 960/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.86

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: rBf6cb5f54494e
Worked: (optional)

Short description of error
I create a template_list to which I pass the data written to bpy.types.WindowManager.test.
If I change something in the template_list window and undo action, I get a сrash.

If I create a template_list to which I pass the data written to bpy.types.Scene.test.
And after the changes and the subsequent cancellation, Blender continues to work.

Exact steps for others to reproduce the error

import bpy


class ObjectLists(bpy.types.PropertyGroup):
    object: bpy.props.PointerProperty(type=bpy.types.Object)


class ObjectsGroup(bpy.types.PropertyGroup):
    name: bpy.props.StringProperty(default="Group Objects")
    objects_lists: bpy.props.CollectionProperty(type=ObjectLists)
    index: bpy.props.IntProperty()

    
class TESTADDON_UL_objects_lists(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        layout.prop(item.object, "name", text="", emboss=False)


class TESTADDON_PT_TestPanel(bpy.types.Panel):
    bl_label = "TestPanel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Test'

    def draw(self, context):
        # scene = context.scene        
        # ObjectsGroup = scene.ObjectsGroup
        wm = context.window_manager
        ObjectsGroup = wm.ObjectsGroup
        layout = self.layout
        layout.operator(TESTADDON_OT_make_coll.bl_idname, text="Refresh list objects")
        layout.template_list("TESTADDON_UL_objects_lists", "", ObjectsGroup, "objects_lists", ObjectsGroup, "index")


class TESTADDON_OT_make_coll(bpy.types.Operator):
    bl_idname = "testaddon.make_coll"
    bl_label = ""

    def execute(self, context):
        # ObjectsGroup = context.scene.ObjectsGroup
        ObjectsGroup = context.window_manager.ObjectsGroup
        ObjectsGroup.objects_lists.clear()
        for obj in context.scene.objects:
            objects_lists = ObjectsGroup.objects_lists.add()
            objects_lists.object = obj
        return {'FINISHED'}

classes = (
    ObjectLists,
    ObjectsGroup,
    
    TESTADDON_UL_objects_lists,
    TESTADDON_OT_make_coll,
    TESTADDON_PT_TestPanel
)


def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
        
    #bpy.types.Scene.ObjectsGroup = bpy.props.PointerProperty(type=ObjectsGroup)
    bpy.types.WindowManager.ObjectsGroup = bpy.props.PointerProperty(type=ObjectsGroup)


def unregister():
    #del bpy.types.Scene.ObjectsGroup
    del bpy.types.WindowManager.ObjectsGroup
    
    from bpy.utils import unregister_class
    for cls in reversed(classes_property):
        unregister_class(cls)


if __name__ == "__main__":
    register()

Details

Type
Bug