Page MenuHome

Fix accessing attribute data in editmode
ClosedPublic

Authored by Philipp Oeser (lichtwerk) on Apr 21 2022, 12:47 PM.

Details

Summary

When in mesh editmode, attributes point to bmesh customdata, the
attribute data is empty since custom data is stored per element instead
of a single array there (same es UVs etc.).
Opposed to e.g. UVs, general attributes were not setting their data
length/size to zero in case of editmode though, which could lead to

  • crash in Outliner Data Api view [that was reported in T95922]
  • RuntimeError such as the following:
RuntimeError: bpy_prop_collection[index]: internal error, valid index 0
given in 8 sized collection, but value not found

Now check for mesh editmode in BKE_id_attribute_data_length (and
return zero in that case).
Alternatively, the check could also be done in
rna_Attribute_data_length only (such as UVs do in
rna_MeshUVLoopLayer_data_length).

Ref D11998
Fixes T95922

Diff Detail

Repository
rB Blender

Event Timeline

Philipp Oeser (lichtwerk) requested review of this revision.Apr 21 2022, 12:47 PM
Philipp Oeser (lichtwerk) created this revision.

Perhaps if (BKE_object_data_editmode_flush_ptr_get(id)) could make this more generic, but I'm not sure that's really better, so patch as is seems ok.

This revision is now accepted and ready to land.Apr 21 2022, 4:17 PM

I think it makes sense that the crash is fixed the same way it is fixed for uvs (and possibly other attributes?).

I think it makes sense that the crash is fixed the same way it is fixed for uvs (and possibly other attributes?).

Does this mean you prefer to have it in rna_Attribute_data_length?

Does this mean you prefer to have it in rna_Attribute_data_length?

Yeah, but I don't have a too strong opinion on that, not sure if it matters much. If the current solution is fine for Brecht, then it's fine for me as well.