Skip to content

Commit a3bd371

Browse files
committed
Fixed crash deleting nodes
1 parent d173e0f commit a3bd371

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

Libs/Framework/Include/AST/Pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ namespace Rift::AST
464464

465465

466466
public:
467-
TPool(AST::Tree& ast) : Pool(ast, DeletionPolicy::InPlace) {}
467+
TPool(AST::Tree& ast) : Pool(ast, DeletionPolicy::Swap) {}
468468
~TPool() override
469469
{
470470
Reset();

Libs/Framework/Src/AST/Filtering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ namespace Rift::AST
185185
const Pool* iterablePool = pools[smallestIdx];
186186
pools.RemoveAtSwap(smallestIdx);
187187

188-
ids.Empty();
188+
ids.Empty(false);
189189
ids.Append(iterablePool->begin(), iterablePool->end());
190190

191191
for (const Pool* pool : pools)

Libs/Framework/Src/AST/Utils/Statements.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ namespace Rift::AST::Statements
4040
else
4141
{
4242
outputNode = Hierarchy::GetParent(ast, outputPin);
43-
Log::Error("{}", outputNode);
4443
if (IsNone(outputNode))
4544
{
4645
return false;

Tests/AST/Filtering.spec.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ go_bandit([]() {
4141
AST::Id id2;
4242
AST::Id id3;
4343
AST::Id id4;
44+
AST::Id id5;
4445
describe("AST.Filtering", [&]() {
4546
before_each([&]() {
4647
ast = {};
4748
id1 = ast.Create();
4849
id2 = ast.Create();
4950
id3 = ast.Create();
5051
id4 = ast.Create();
52+
id5 = ast.Create();
5153
ast.Add<Type>(id1);
5254
ast.Add<Type, TypeTwo, TypeThree>(id2);
5355
ast.Add<TypeTwo, TypeThree>(id3);
5456
ast.Add<TypeTwo, TypeThree>(id4);
57+
ast.Add<TypeTwo>(id5);
5558
});
5659

5760
describe("ListAny/ListAll", [&]() {
@@ -84,10 +87,12 @@ go_bandit([]() {
8487
it("Doesn't list removed ids", [&]() {
8588
TAccess<TypeTwo> access{ast};
8689
ast.Destroy(id2); // Remove first in the pool
90+
ast.Destroy(id3); // Remove last in the pool
8791
ast.Destroy(id4); // Remove last in the pool
8892

8993
TArray<AST::Id> ids = AST::ListAll<TypeTwo>(access);
9094
AssertThat(ids.Contains(AST::NoId), Is().False());
95+
AssertThat(ids.Size(), Equals(1));
9196
});
9297
});
9398

0 commit comments

Comments
 (0)