Skip to content
Snippets Groups Projects
Commit 201b8271 authored by Robert Meerman's avatar Robert Meerman Committed by Aaron Keith
Browse files

Corrected resource leak when adding in EDIT mode

Patch D10035

Addon: Bolt Factory: Corrected resource leak when adding in EDIT mode

Adding a bolt while in edit mode would *replace* the current object's mesh data block with a new one, and then fail to remove the original mesh data block.

Now the original mesh is updated in-place, preserving its name and avoiding orphan data blocks.
parent a5587f52
No related branches found
No related tags found
No related merge requests found
...@@ -449,17 +449,14 @@ class add_mesh_bolt(Operator, AddObjectHelper): ...@@ -449,17 +449,14 @@ class add_mesh_bolt(Operator, AddObjectHelper):
obj.data[prm] = getattr(self, prm) obj.data[prm] = getattr(self, prm)
if bpy.context.mode == "EDIT_MESH": if bpy.context.mode == "EDIT_MESH":
active_object = context.active_object obj = context.edit_object
name_active_object = active_object.name
bpy.ops.object.mode_set(mode='OBJECT')
mesh = createMesh.Create_New_Mesh(self, context) mesh = createMesh.Create_New_Mesh(self, context)
obj = object_utils.object_data_add(context, mesh, operator=self)
obj.select_set(True) bm = bmesh.from_edit_mesh(obj.data) # Access edit mode's mesh data
active_object.select_set(True) bm.from_mesh(mesh) # Append new mesh data
bpy.ops.object.join() bmesh.update_edit_mesh(obj.data) # Flush changes (update edit mode's view)
context.active_object.name = name_active_object
bpy.ops.object.mode_set(mode='EDIT') bpy.data.meshes.remove(mesh) # Remove temporary mesh
return {'FINISHED'} return {'FINISHED'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment