When Tmap's find function called, access violation error occur

TigerFish89
Thu, 07 Mar 2019 07:14:15 +0000
C++

Hi. When I open my character blueprint, my game have been shutdown with below error message sometime. I just try find value in TMap. And I declare UPROPERTY on the TMap value for Garbage Collector. But It is now work well. I don’t know what am I miss. Help me please.(My trouble code is below)

Access violation - code c0000005
(first/second chance not available)

UE4Editor_SavingGame_6234!UJsonLoader::GetJson()
[d:\unreal
project\mine\source\savinggame\instance\manager\data\jsonloader.cpp:101]
UE4Editor_SavingGame_6234!UBaseAnimInstance::Set()
[d:\unreal
project\mine\source\savinggame\animation\baseaniminstance.cpp:130]
UE4Editor_SavingGame_6234!ABaseCharacter::PostInitializeComponents()
[d:\unreal
project\mine\source\savinggame\character\basecharacter.cpp:85]

JsonLoader.h

UCLASS()
class SAVINGGAME_API UJsonLoader : public UObject
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Json loader")
	TMap<FString, UJsonData*> _JsonMap;

private:
	TSharedPtr<FJsonObject> ReadJson(FString in_path);

public:
	UJsonLoader();
	UFUNCTION()
	UJsonData* GetJson(EJsonData in_json);
};

JsonLoader.cpp

UJsonData* UJsonLoader::GetJson(EJsonData in_json)
{
	FString json = UEnumUtile::GetString(in_json);
	UJsonData* data = _JsonMap.FindRef(json);

	if (nullptr == data)
	{
		UDebugManager::LogError(FString("Get json missing - name : ") + json);
		return nullptr;
	}

	return data;
}

2 posts - 1 participant