diff --git a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Container.cpp b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Container.cpp index 4584a5a..09b962c 100644 --- a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Container.cpp +++ b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Container.cpp @@ -227,7 +227,7 @@ TSharedPtr Ink::FContainer::GetContentWithPathComponent(const Ink: else if (InComponent.IsParent()) { - return Parent; + return Parent.Pin(); } else diff --git a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Object.cpp b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Object.cpp index bb700d2..d75eff0 100644 --- a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Object.cpp +++ b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Private/Ink/Object.cpp @@ -30,7 +30,7 @@ int32 Ink::FObject::GetHashCode() TSharedPtr Ink::FObject::GetParent() const { - return Parent; + return Parent.Pin(); } void Ink::FObject::SetParent(TSharedPtr InParent) @@ -68,7 +68,7 @@ TSharedPtr Ink::FObject::GetPath() } child = container; - container = DynamicCastTo(container->Parent); + container = DynamicCastTo(container->Parent.Pin()); } Algo::Reverse(componentsStack); // explicitly reverse the array, instead of copying the c# code's implicit technique of handing over a stack to an array @@ -87,7 +87,7 @@ Ink::FSearchResult Ink::FObject::ResolvePath(TSharedPtr InPath) if (!nearestContainer.IsValid()) { ensureAlwaysMsgf(Parent != nullptr, TEXT("Can't resolve relative path because we don't have a parent")); - nearestContainer = DynamicCastTo(Parent); + nearestContainer = DynamicCastTo(Parent.Pin()); ensureAlwaysMsgf(nearestContainer != nullptr, TEXT("Expected parent to be a container")); ensureAlways(InPath->GetComponent(0)->IsParent()); InPath = InPath->GetTail(); @@ -106,7 +106,7 @@ TSharedPtr Ink::FObject::GetRootContentContainer() TSharedPtr ancestor = this->AsShared(); while (ancestor->Parent.IsValid()) { - ancestor = ancestor->Parent; + ancestor = ancestor->Parent.Pin(); } return FObject::DynamicCastTo(ancestor); @@ -204,7 +204,7 @@ TSharedPtr Ink::FObject::GetDebugMetadata() const { if (Parent.IsValid()) { - return Parent->DebugMetadata; + return Parent.Pin()->DebugMetadata; } } diff --git a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Public/Ink/Object.h b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Public/Ink/Object.h index 99369ba..b3a2df9 100644 --- a/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Public/Ink/Object.h +++ b/InkpotDemo/Plugins/Inkpot/Source/InkPlusPlus/Public/Ink/Object.h @@ -76,7 +76,7 @@ namespace Ink // StoryException being static is causing problems during the tests as it isn't always resetting between runs. Currently using simple logging instead of this protected: - TSharedPtr Parent; + TWeakPtr Parent; TSharedPtr _Path; TSharedPtr DebugMetadata; Ink::FContainer* RootContentContainer;