Hey,
I’m having sporadic crashes in UE-Editor during testing of my inventory system PLUGIN. Some kind of invalid pointers most likely, maybe GC issue, but I can’t track it down, it’s several weeks now .
I have a ItemBasic abstract c++ base class to represent an item base properties (Name, Desc, Weight, Value) and all other item types derive from it. They add some extra data on top of it using derived struct and override some virtual methods of ItemBase class, like ItemArmor.
Error:
ItemBasic.gen.cpp:
DEFINE_FUNCTION(UItemBasic::execGetBase)
{
P_GET_STRUCT_REF(FItemBaseRow,Z_Param_Out_outBase);
P_FINISH;
P_NATIVE_BEGIN;
P_THIS->GetBase(Z_Param_Out_outBase); // CRASH HAPPENS HERE
P_NATIVE_END;
}
ItemBasic.h
UCLASS(Blueprintable, Abstract)
class INVENTORYANDINTERACTION_API UItemBasic : public UObject
{
GENERATED_BODY()
/* OMMITED */
public:
UFUNCTION(BlueprintCallable, Category = Inventory|Item)
virtual void GetBase(FItemBaseRow& outBase) const;
}
ItemBasic.cpp:
void UItemBasic::GetBase(FItemBaseRow& outBase) const
{
outBase = FItemBaseRow::Empty; // static const value, should be always initialized
}
ItemArmor.h
UCLASS(Blueprintable)
class INVENTORYANDINTERACTION_API UItemArmor : public UItemBasic
{
GENERATED_BODY()
/* OMMITED */
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory|Item)
FItemArmorRow Extra;
virtual void GetBase(FItemBaseRow& outBase) const override;
}
ItemArmor.cpp
void UItemArmor::GetBase(FItemBaseRow& outBase) const
{
outBase = Extra;
}
I’m using structures inheritance in C++ and it works with BPs without issues, I can upcast/downcast in C++ and pass to BPs, FTableRowBase also works as intended.
USTRUCT(BlueprintType)
struct FItemBaseRow : public FTableRowBase
{
GENERATED_BODY()
public:
/* PROPERTIES */
static const FItemBaseRow Empty;
}
USTRUCT(BlueprintType)
struct FItemArmorRow : public FItemBaseRow
{
GENERATED_BODY()
public:
/* PROPERTIES */
}
Any experienced C++ DEV to help?