From 515f2a059e6384e4df55a8645a646aebb626f19c Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 18 Mar 2020 23:07:36 -0400 Subject: avoid infinite recursion --- lib/extensions/convert_to_satin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/extensions/convert_to_satin.py') diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index cf292281..f3924659 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -54,7 +54,7 @@ class ConvertToSatin(InkstitchExtension): parent.remove(element.node) - def convert_path_to_satins(self, path, stroke_width, style_args, correction_transform, path_style): + def convert_path_to_satins(self, path, stroke_width, style_args, correction_transform, path_style, depth=0): try: rails, rungs = self.path_to_satin(path, stroke_width, style_args) yield self.satin_to_svg_node(rails, rungs, correction_transform, path_style) @@ -62,11 +62,16 @@ class ConvertToSatin(InkstitchExtension): # The path intersects itself. Split it in two and try doing the halves # individually. + if depth >= 20: + # At this point we're slicing the path way too small and still + # getting nowhere. Just give up on this section of the path. + return + half = int(len(path) / 2.0) halves = [path[:half + 1], path[half:]] for path in halves: - for satin in self.convert_path_to_satins(path, stroke_width, style_args, correction_transform, path_style): + for satin in self.convert_path_to_satins(path, stroke_width, style_args, correction_transform, path_style, depth=depth + 1): yield satin def fix_loop(self, path): -- cgit v1.2.3