Solving BMesh concurrency issues
I have a "fairly" complicated script that requires bmesh to be run in a handler, I only reference BMesh data in this situation, so I create and free meshes immediately (exclusively in edit mode) without changing anything.
It seems a bmesh of a particular mesh data is shared between different scripts that may have called it (which makes a kind of sense). The problem manifests when something like UVPackmaster does it's heuristic pack (a modal operator) that references and updates the bmesh, then my script comes in and creates (or merely references and already created, in this case) bmesh, then frees it immediately, breaking UVPackmaster.
So the solution to this kind of problem would be a mechanism to check if there is something else that references this bmesh, and only truly freeing it if all interested parties have freed it from their end.
A method of checking if we're the only ones using a bmesh would also help write scripts hardened against this kind of issue.
0 Comments