Page MenuHome

Blender crashes when trying to copy a PointerProperty to selected objects
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows 10

Blender Version
Broken: 2.81 stable

Short description of error
When you have a PointerProperty shown in a panel, if you try to copy to selected, Blender will crash.

Exact steps for others to reproduce the error

  1. Start up a fresh Blender
  2. Run the following code to add a pointer property.
import bpy

class Test(bpy.types.PropertyGroup):
    foo: bpy.props.PointerProperty(name='Foo', type=bpy.types.Object)
    
class FOO_PT_object(bpy.types.Panel):
    bl_label = 'Foo Bar'
    bl_idname = 'BIM_PT_object'
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = 'object'

    @classmethod
    def poll(cls, context):
        return context.active_object is not None and hasattr(context.active_object, 'Test')

    def draw(self, context):
        row = self.layout.row()
        row.prop(context.active_object.Test, 'foo')

    
bpy.utils.register_class(Test)
bpy.utils.register_class(FOO_PT_object)
bpy.types.Object.Test = bpy.props.PointerProperty(type=Test)
  1. Duplicate the default cube a few times and set the Foo property on one of the cubes.
  2. Select another few cubes, then right click on the Foo property and try Copy to Selected
  3. Blender crashes.

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Jan 23 2020, 12:32 PM
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Confirmed, checking...

I guess this is for @Bastien Montagne (mont29), this works seems related:
rB1cab3be7a7af: Significant step toward supporting IDProperties in new RNA diff code.
rBba10cd49220a: LibOverride: Fix last main issue with overriding custom properties.

Crash first looks like it is only relating to reports [reports is passed as NULL, so cannot really work here], but even if reports are left out Copy To Selected wont work (the PointerProperties are not set on the targets)...
I think the problem already starts in RNA_property_copy where rna_ensure_property_realdata will return IDProperty but is treated like PropertyRNA (so looks like pointer property is read as boolean property...)
@Bastien Montagne (mont29): does this need some RNA_MAGIC treatment somewhere along the way?

1  RNA_property_pointer_set              rna_access.c                  3769  0x36e3af3 
2  rna_property_override_apply_default   rna_rna.c                     2437  0x3818e51 
3  rna_property_override_operation_apply rna_access_compare_override.c 555   0x36ef35a 
4  RNA_property_copy                     rna_access_compare_override.c 171   0x36ee77c 
5  copy_to_selected_button               interface_ops.c               965   0x3df9211 
6  copy_to_selected_button_exec          interface_ops.c               993   0x3df9301 
7  wm_operator_invoke                    wm_event_system.c             1269  0x32886ac 
8  wm_operator_call_internal             wm_event_system.c             1504  0x3288e92 
9  WM_operator_name_call_ptr             wm_event_system.c             1518  0x3288f4f 
10 ui_apply_but_funcs_after              interface_handlers.c          877   0x3dc625e 
11 ui_popup_handler                      interface_handlers.c          10748 0x3ddfb3b 
12 wm_handler_ui_call                    wm_event_system.c             617   0x3286ce0 
13 wm_handlers_do_intern                 wm_event_system.c             2543  0x328b8ca 
14 wm_handlers_do                        wm_event_system.c             2789  0x328c57c 
15 wm_event_do_handlers                  wm_event_system.c             3168  0x328d766 
16 WM_main                               wm.c                          417   0x328213b 
17 main                                  creator.c                     518   0x2fb5396

@Philipp Oeser (lichtwerk) not really related to those commits, no… Also, all BKE_report API in Blender supports a NULL report pointer, it just prints error message to system console then. ;)

To summarize, issue is in assigning code of RNA_pointer properties, when IDProps are involved. Made some progresses already, but after several hours am still not fully done with this… IDProps and RNA are already a nightmare, but for some reasons ID pointers IDProps are even more nightmarish. :(