Make component refs into strrong pointers

This commit is contained in:
2026-04-08 03:35:47 -04:00
parent 15beb42d5f
commit f4286faeb1
8 changed files with 20 additions and 18 deletions

View File

@@ -65,12 +65,12 @@ public:
if (!UWingComponent::CheckValidComponentClass(ComponentClass, WingOut::Stdout)) return;
// Find the specified parent component
TArray<UWingComponentReference*> AllComponents = UWingComponent::GetAll(BP);
UWingComponentReference* ParentComp = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout);
TArray<TStrongObjectPtr<UWingComponentReference>> AllComponents = UWingComponent::GetAll(BP);
TStrongObjectPtr<UWingComponentReference> ParentComp = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout);
if (!ParentComp) return;
// Create the SCS node
if (!UWingComponent::AddComponent(BP, ComponentClass, ParentComp, InternalID, WingOut::Stdout)) return;
if (!UWingComponent::AddComponent(BP, ComponentClass, ParentComp.Get(), InternalID, WingOut::Stdout)) return;
WingOut::Stdout.Printf(TEXT("Component Added.\n"));
}

View File

@@ -39,11 +39,11 @@ public:
// Find the new parent among all components (if specified)
UBlueprint *BP = CompRef->BP;
TArray<UWingComponentReference*> AllComponents = UWingComponent::GetAll(BP);
UWingComponentReference* NewParent = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout);
TArray<TStrongObjectPtr<UWingComponentReference>> AllComponents = UWingComponent::GetAll(BP);
TStrongObjectPtr<UWingComponentReference> NewParent = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout);
if (!NewParent) return;
if (!UWingComponent::ReparentComponent(CompRef, NewParent, WingOut::Stdout)) return;
if (!UWingComponent::ReparentComponent(CompRef, NewParent.Get(), WingOut::Stdout)) return;
WingOut::Stdout.Printf(TEXT("Reparented component."));
}

View File

@@ -69,7 +69,7 @@ public:
BlueprintVars.Print(WingOut::StdoutBuffer);
// Components
TArray<UWingComponentReference*> Components = UWingComponent::GetAll(BP);
TArray<TStrongObjectPtr<UWingComponentReference>> Components = UWingComponent::GetAll(BP);
if (!Components.IsEmpty()) WingOut::Stdout.Print(TEXT("\nComponents:\n"));
UWingComponent::PrintAll(BP, WingOut::Stdout);

View File

@@ -244,9 +244,9 @@ UActorComponent* UWingComponent::GetMutableTemplate(const UWingComponentReferenc
return Override;
}
TArray<UWingComponentReference*> UWingComponent::GetAll(UBlueprint* BP)
TArray<TStrongObjectPtr<UWingComponentReference>> UWingComponent::GetAll(UBlueprint* BP)
{
TArray<UWingComponentReference*> Result;
TArray<TStrongObjectPtr<UWingComponentReference>> Result;
if (!BP) return Result;
// Find the native ancestor class
@@ -264,7 +264,7 @@ TArray<UWingComponentReference*> UWingComponent::GetAll(UBlueprint* BP)
UWingComponentReference* Ref = NewObject<UWingComponentReference>();
Ref->BP = BP;
Ref->VariableName = Comp->GetFName();
Result.Add(Ref);
Result.Emplace(Ref);
}
}
}
@@ -278,7 +278,7 @@ TArray<UWingComponentReference*> UWingComponent::GetAll(UBlueprint* BP)
UWingComponentReference* Ref = NewObject<UWingComponentReference>();
Ref->BP = BP;
Ref->VariableName = Node->GetVariableName();
Result.Add(Ref);
Result.Emplace(Ref);
}
}

View File

@@ -284,19 +284,19 @@ WingFetcher& WingFetcher::Component(const FString& Value)
return SetError();
}
TArray<UWingComponentReference*> AllComponents = UWingComponent::GetAll(BP);
UWingComponentReference* Found = WingUtils::FindOneWithExternalID(Value, AllComponents, TEXT("component"), Errors);
TArray<TStrongObjectPtr<UWingComponentReference>> AllComponents = UWingComponent::GetAll(BP);
TStrongObjectPtr<UWingComponentReference> Found = WingUtils::FindOneWithExternalID(Value, AllComponents, TEXT("component"), Errors);
if (!Found)
{
Errors.Printf(TEXT("Components that exist in the blueprint:\n"));
for (const UWingComponentReference* C : AllComponents)
for (const TStrongObjectPtr<UWingComponentReference>& C : AllComponents)
{
Errors.Printf(TEXT(" %s\n"), *WingUtils::FormatName(C));
Errors.Printf(TEXT(" %s\n"), *WingUtils::FormatName(C.Get()));
}
return SetError();
}
SetObj(Found);
SetObj(Found.Get());
return *this;
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include "CoreMinimal.h"
#include "UObject/StrongObjectPtr.h"
class UBlueprint;
class USCS_Node;
@@ -22,7 +23,7 @@ public:
static bool AddComponent(UBlueprint *BP, UClass *Class,
UWingComponentReference *Parent, FName Name, WingOut Errors);
static TArray<UWingComponentReference*> GetAll(UBlueprint* BP);
static TArray<TStrongObjectPtr<UWingComponentReference>> GetAll(UBlueprint* BP);
static void PrintAll(UBlueprint* BP, WingOut Out);
static bool CheckValidComponentClass(UClass *Class, WingOut Errors);

View File

@@ -104,7 +104,7 @@ private:
const FString& Request, FString& Response);
static void WaitForAssetRegistry();
// ----- Thread-safe message queue -----
// ----- The Critical Section -----
struct FPendingMessage
{
FString Line;

View File

@@ -64,6 +64,7 @@ public:
static FName GetFName(const FUserPinInfo &Pin) { return Pin.PinName; }
static FName GetFName(const TSharedPtr<FUserPinInfo> &Pin) { return Pin->PinName; }
static FName GetFName(const UWingComponentReference *Ref) { return Ref->VariableName; }
static FName GetFName(const TStrongObjectPtr<UWingComponentReference> &Ref) { return Ref->VariableName; }
static FName GetFName(const UWidget *Widget) { return Widget->GetFName(); }
static FName GetFName(const WingVariables::Var &Var) { return Var.Name; }