Skip to content

Commit

Permalink
Reset current iterator in LinkedList upon clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
Xrayez committed Aug 5, 2021
1 parent cb708de commit be95465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/types/linked_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ void LinkedList::clear() {
while (get_front()) {
memdelete(get_front());
}
_iter_current = nullptr;
}

String LinkedList::to_string() {
Expand Down
7 changes: 7 additions & 0 deletions tests/project/goost/core/types/test_linked_list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,10 @@ class TestInvalidData extends "res://addons/gut/test.gd":
list.move_before(node_b, null)
node_b.free()
assert_true(list.empty())

func test_iter():
var _n = list.push_front(Array([]))
list._iter_init(Array([]))
list.clear()
var _b = list._iter_get(Array([]))
assert_true(list.empty())

0 comments on commit be95465

Please sign in to comment.