Skip to content

Commit

Permalink
fix: move the vertices/edges selected polling methods into the invoke…
Browse files Browse the repository at this point in the history
… method for the edge_bevel, vertex_bevel, and clear_vgs operators to avoid freeing any existing object's BMesh instance
  • Loading branch information
tristan-hm committed Nov 19, 2024
1 parent 179ab7a commit 7ae5a2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion bevels/edge_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def do_modal(self, context, event):
def do_invoke(self, context, event):
if context.active_object is None:
self.report({'ERROR_INVALID_INPUT'}, "No active target object selected.")

if not obj_edges_selected(context.active_object):
self.report({'INFO'}, "No edges selected.")
return {'CANCELLED'}

if event.ctrl:
Expand Down Expand Up @@ -242,7 +245,7 @@ def do_invoke(self, context, event):
@classmethod
def poll(cls, context):
target_object = context.active_object
return ctx_edit_mode(context) and obj_is_mesh(target_object) and obj_edges_selected(target_object)
return ctx_edit_mode(context) and obj_is_mesh(target_object)


def prepare_new_operator(self, context):
Expand Down
5 changes: 4 additions & 1 deletion bevels/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def do_modal(self, context, event):
def do_invoke(self, context, event):
if context.active_object is None:
self.report({'ERROR_INVALID_INPUT'}, "No active target object selected.")

if not obj_verts_selected(context.active_object):
self.report({'INFO'}, "No vertices selected.")
return {'CANCELLED'}

if event.ctrl:
Expand Down Expand Up @@ -232,7 +235,7 @@ def do_invoke(self, context, event):
@classmethod
def poll(cls, context):
target_object = context.active_object
return ctx_edit_mode(context) and obj_is_mesh(target_object) and obj_verts_selected(target_object)
return ctx_edit_mode(context) and obj_is_mesh(target_object)


def summon_old_operator(self, context):
Expand Down
5 changes: 4 additions & 1 deletion sketch/clear_vgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ class ND_OT_clear_vgs(bpy.types.Operator):
@classmethod
def poll(cls, context):
target_object = context.active_object
return ctx_edit_mode(context) and obj_exists(target_object) and obj_verts_selected(target_object)
return ctx_edit_mode(context) and obj_exists(target_object)


def execute(self, context):
if context.active_object is None:
self.report({'ERROR_INVALID_INPUT'}, "No active target object selected.")

if not obj_verts_selected(context.active_object):
self.report({'INFO'}, "No vertices selected.")
return {'CANCELLED'}

bm = bmesh.from_edit_mesh(context.active_object.data)
Expand Down

0 comments on commit 7ae5a2b

Please sign in to comment.