Skip to content

Commit

Permalink
make remove commands more robust for broken commands with active sele…
Browse files Browse the repository at this point in the history
…ction (inkstitch#3288)
  • Loading branch information
kaalleen authored Nov 19, 2024
1 parent 8a4afa1 commit 7c0e1d0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/extensions/remove_embroidery_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from inkex import NSS, Boolean, ShapeElement

from ..commands import OBJECT_COMMANDS, find_commands
from ..commands import OBJECT_COMMANDS, find_commands, is_command_symbol
from ..svg.svg import find_elements
from .base import InkstitchExtension

Expand Down Expand Up @@ -77,10 +77,19 @@ def remove_specific_commands(self, command):
self.remove_elements(symbols)

def remove_selected_commands(self):
del_option = self.options.del_commands
elements = self.get_selected_elements()
for element in elements:
if is_command_symbol(element) and (del_option in element.get('xlink:href') or del_option == 'all'):
group = element.getparent()
if group.getparent() is not None:
if group.get_id().startswith("command_group"):
group.getparent().remove(group)
else:
group.remove(element)
continue
for command in find_commands(element):
if self.options.del_commands in ('all', command.command):
if del_option in ('all', command.command):
group = command.connector.getparent()
group.getparent().remove(group)

Expand Down

0 comments on commit 7c0e1d0

Please sign in to comment.