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
Branches
Tags
No related merge requests found
......@@ -449,17 +449,14 @@ class add_mesh_bolt(Operator, AddObjectHelper):
obj.data[prm] = getattr(self, prm)
if bpy.context.mode == "EDIT_MESH":
active_object = context.active_object
name_active_object = active_object.name
bpy.ops.object.mode_set(mode='OBJECT')
obj = context.edit_object
mesh = createMesh.Create_New_Mesh(self, context)
obj = object_utils.object_data_add(context, mesh, operator=self)
obj.select_set(True)
active_object.select_set(True)
bpy.ops.object.join()
context.active_object.name = name_active_object
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(obj.data) # Access edit mode's mesh data
bm.from_mesh(mesh) # Append new mesh data
bmesh.update_edit_mesh(obj.data) # Flush changes (update edit mode's view)
bpy.data.meshes.remove(mesh) # Remove temporary mesh
return {'FINISHED'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment