My code crashes using this method…
My map contains the structures inside (TMap<int32, FMyStruct>). And FMyStruct has int32 and FString fields.
My method _IterateStruct iterates by all types (include TArray, all basic types and UStructs).
But I also want to add TMap to this list.
if (UMapProperty* Prop = Cast<UMapProperty>(Property))
{
void* ptr = Prop->ContainerPtrToValuePtr<void>(StructPtr);
FScriptMapHelper ScriptMapHelper(Prop, ptr);
const int32 ElementCount = ScriptMapHelper.Num();
TArray<FString> keys;
TArray<FString> values;
for (int32 j = 0; j < ElementCount; ++j)
{
if (!ScriptMapHelper.IsValidIndex(j))
continue;
const uint8* MapPairPtr = ScriptMapHelper.GetPairPtr(j);
result = _ParseObject(Prop->KeyProp, (void*)(MapPairPtr + Prop->MapLayout.KeyOffset));
keys.Add(result);
result = _ParseObject(Prop->ValueProp, (void*)(MapPairPtr + Prop->MapLayout.ValueOffset));
values.Add(result);
}
result = FString::Printf(TEXT("\"%s\": [[%s], [%s]]"), *child->GetName(), *FString::Join(keys, TEXT(", ")), *FString::Join(values, TEXT(", ")));
}
And got crash in gathring FString data. Can I show my code for revision?