I am writing an Addon. I have a list of Vectors:
centers = [p.center for p in obj.data.polygons]
In a later section of code, I do the following to a different object:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='OBJECT')
After this return to Object Mode, the earlier list of centers no longer points to anything, and any reference to it causes a segfault.
This is not the only mode change in the code, but the segfault happens only at this one location. The segfault remains even if I operate on centers_copy = centers.copy(). The segfault goes away if I inelegantly cast the Vectors to lists and back:
centers_list = [list(elt) for elt in centers]
centers = [Vector(elt) for elt in centers_list]
What, precisely, is causing this segfault?
Thanks in advance.