Validating icon_ids

Is there some way to validate some icon id I got from ID.preview.icon_id (as in object.preview.icon_id, material.preview.icon_id) or from preview_collection[some_id].icon_id?

If it’s invalid then blender crashes with EXCEPTION_ACCESS_VIOLATION if you provide invalid icon id as icon_value UILayout.prop, UILayout.operator.
It seems to be the only way to do it is to try to draw it with one of the UILayout functions and experience the crash.

I understand that it shouldn’t get invalidated in the first place and there is another root cause but just looking for a way to debug when exactly the icons I store got invalidated.

1 Like