Hey I’m playing around with FMapProperty::ImportText_Internal function to try and figure out how it works. But the problem is when ever I put AddOnScreenDebugMessage in it to see how it executes It doesn’t print to screen.
I’ve tried removing AddOnScreenDebugMessage from the if statement, and it doesn’t crash so I don’t think the problem is that it can’t access GEngine.
I’ve noticed this with other parts of the engine source code as wall when I try to test it, can any one explain why its not working.
Example code
const TCHAR* FMapProperty::ImportText_Internal(const TCHAR* Buffer, void* Data, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText) const
{
//Not working
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Some debug message!"));
checkSlow(KeyProp);
checkSlow(ValueProp);
FScriptMapHelper MapHelper(this, Data);
MapHelper.EmptyValues();
// If we export an empty array we export an empty string, so ensure that if we're passed an empty string
// we interpret it as an empty array.
if (*Buffer++ != TCHAR('('))
{
return nullptr;
}
SkipWhitespace(Buffer);
if (*Buffer == TCHAR(')'))
{
return Buffer + 1;
}
uint8* TempPairStorage = (uint8*)FMemory::Malloc(MapLayout.ValueOffset + ValueProp->ElementSize);
bool bSuccess = false;
ON_SCOPE_EXIT
{
FMemory::Free(TempPairStorage);
// If we are returning because of an error, remove any already-added elements from the map before returning
// to ensure we're not left with a partial state.
if (!bSuccess)
{
MapHelper.EmptyValues();
}
};
for (;;)
{
KeyProp->InitializeValue(TempPairStorage);
ValueProp->InitializeValue(TempPairStorage + MapLayout.ValueOffset);
ON_SCOPE_EXIT
{
ValueProp->DestroyValue(TempPairStorage + MapLayout.ValueOffset);
KeyProp->DestroyValue(TempPairStorage);
};
if (*Buffer++ != TCHAR('('))
{
return nullptr;
}
// Parse the key
SkipWhitespace(Buffer);
Buffer = KeyProp->ImportText(Buffer, TempPairStorage, PortFlags | PPF_Delimited, Parent, ErrorText);
if (!Buffer)
{
return nullptr;
}
// Skip this element if it's already in the map
bool bSkip = MapHelper.FindMapIndexWithKey(TempPairStorage) != INDEX_NONE;
SkipWhitespace(Buffer);
if (*Buffer++ != TCHAR(','))
{
return nullptr;
}
// Parse the value
SkipWhitespace(Buffer);
Buffer = ValueProp->ImportText(Buffer, TempPairStorage + MapLayout.ValueOffset, PortFlags | PPF_Delimited, Parent, ErrorText);
if (!Buffer)
{
return nullptr;
}
SkipWhitespace(Buffer);
if (*Buffer++ != TCHAR(')'))
{
return nullptr;
}
if (!bSkip)
{
int32 Index = MapHelper.AddDefaultValue_Invalid_NeedsRehash();
uint8* PairPtr = MapHelper.GetPairPtrWithoutCheck(Index);
// Copy over imported key and value from temporary storage
KeyProp ->CopyCompleteValue_InContainer(PairPtr, TempPairStorage);
ValueProp->CopyCompleteValue_InContainer(PairPtr, TempPairStorage);
}
SkipWhitespace(Buffer);
switch (*Buffer++)
{
case TCHAR(')'):
MapHelper.Rehash();
bSuccess = true;
return Buffer;
case TCHAR(','):
SkipWhitespace(Buffer);
break;
default:
return nullptr;
}
}
}