Skip to content

Commit 72a8ef6

Browse files
authored
Fix path conversion closure condition (#1807)
1 parent 7eb6ded commit 72a8ef6

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/data_classes/ElementPath.gd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ func _solve_quadratic(a: float, b: float, c: float) -> Array[float]:
166166
if is_nan(D):
167167
return []
168168
else:
169-
return [(-b + D) / (2 * a), (-b - D) / (2 * a)]
169+
var double_a := 2 * a
170+
return [(-b + D) / double_a, (-b - D) / double_a]
170171

171172

172173
func can_replace(new_element: String) -> bool:
@@ -210,9 +211,10 @@ func get_replacement(new_element: String) -> Element:
210211
"polygon":
211212
dropped_attributes = PackedStringArray(["points", "d"])
212213
var points := PackedFloat64Array()
213-
# Skip the closure if there are multiple points.
214-
for i in (command_count if command_count < 2 else command_count - 1):
214+
for i in command_count:
215215
var command := pathdata.get_command(i)
216+
if command is PathCommand.CloseCommand:
217+
break
216218
var x: float = command.x if not command is PathCommand.VerticalLineCommand else command.start_x
217219
var y: float = command.y if not command is PathCommand.HorizontalLineCommand else command.start_y
218220
points.append_array(PackedFloat64Array([x, y]))

src/ui_parts/good_file_dialog.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ func _on_file_list_item_multi_selected(index: int, selected: bool) -> void:
461461
if selected:
462462
call_selection_callback(file_list.get_item_metadata(index))
463463

464-
func _on_file_list_item_clicked(index: int, _at_position: Vector2,
465-
mouse_button_index: int) -> void:
464+
func _on_file_list_item_clicked(index: int, _at_position: Vector2, mouse_button_index: int) -> void:
466465
if mouse_button_index == MOUSE_BUTTON_RIGHT:
467466
call_right_click_callback(file_list.get_item_metadata(index))
468467

src/ui_widgets/choose_name_dialog.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ func _on_name_edit_text_submitted(_text: String) -> void:
2727
cancel_button.grab_focus()
2828

2929
# The error/warning callables should take the stripped text and return a string.
30-
func setup(title: String, action: Callable, error_callable := Callable(),
31-
warning_callable := Callable()) -> void:
30+
func setup(title: String, action: Callable, error_callable := Callable(), warning_callable := Callable()) -> void:
3231
title_label.text = title
3332
action_button.pressed.connect(
3433
func() -> void:

src/utils/FileUtils.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,7 @@ class WebSafeFileAccess:
514514
return _file_access.get_length()
515515

516516

517-
static func _web_load_files(allowed_extensions: PackedStringArray,
518-
completion_callback: Callable, multi_select: bool) -> void:
517+
static func _web_load_files(allowed_extensions: PackedStringArray, completion_callback: Callable, multi_select: bool) -> void:
519518
var allowed_extensions_with_dots := PackedStringArray()
520519
for allowed_extension in allowed_extensions:
521520
allowed_extensions_with_dots.append("." + allowed_extension)

0 commit comments

Comments
 (0)