C++ Engine throws Invalid object in GC at random time

Hello,

I am creating Inventory system in C++, whole functionality works fine but I have problem with weird fatal error ,Invalid object in GC" which I got randomly. Sometimes I can play the game like 1 hour, do crazy things with inventory and all works fine. Sometimes I can only press the play button and this error shows up.

Error details:

[File:D:/Build/++UE4+Licensee/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/GarbageCollection.cpp]
[Line: 903] Invalid object in GC:
0x0000005931b79470, ReferencingObject:
InventoryComponent
/Game/ThirdPersonCPP/Maps/UEDPIE_0_HouseMap.HouseMap:PersistentLevel.PlayerCharacter_C_0.InventoryComponent,
ReferencingObjectClass: Class
/Script/CppFinal.InventoryComponent,
Property Name: Thumbnail, Offset: 40,
TokenIndex: 19

It looks like problem with InventoryComponent - FInventoryStructure contains UTexture2D* Thumbnail property, but I dont know whats wrong. Its defined this way:

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Item details")
UTexture2D* Thumbnail;

All looks like this:

  • I have FInventoryStructure (item name, description etc) and FSlotItem (contains FInventoryStructure property and info about quantity)
  • I have InventoryComponent, which contains information about inventory (name, description, number of slots etc) and TArray of the FSlotItem. At Begin play I initialize TArray of FSlotItem like this:

Then Additem method:

DeleteItem method:

322786-deleteitem.png

I tried to set nullptr in deleteItem method and NULL, both same issue…

And then I Have PlayerInventoryWidget which contains CreateInventory (called if player first time open inventory) and UpdateInventory methods

And at the end UInventoryItemWidget containts binding binding on UImage (imgItemThumnail) and UpdateItem method:

Somebody know what can throw this error? Or is there way how to do this better?

I have the same problem/(ㄒoㄒ)/~~Have you solved it?