[Bf-extensions-cvs] [201b8271] master: Corrected resource leak when adding in EDIT mode
Robert Meerman
noreply at git.blender.org
Mon Feb 14 05:59:00 CET 2022
Commit: 201b8271b907bdc0b2ebcee740dc1fa98e832fd4
Author: Robert Meerman
Date: Mon Feb 14 17:55:45 2022 +1300
Branches: master
https://developer.blender.org/rBA201b8271b907bdc0b2ebcee740dc1fa98e832fd4
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.
===================================================================
M add_mesh_BoltFactory/Boltfactory.py
===================================================================
diff --git a/add_mesh_BoltFactory/Boltfactory.py b/add_mesh_BoltFactory/Boltfactory.py
index 501043d1..0c56e9b7 100644
--- a/add_mesh_BoltFactory/Boltfactory.py
+++ b/add_mesh_BoltFactory/Boltfactory.py
@@ -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'}
More information about the Bf-extensions-cvs
mailing list