i am trying to set a “linera colour” variable"s value using ReflectionSystem"s ImportText() .
declaration of that func is:
//Source\Runtime\CoreUObject\Public\UObject\Class.h
/**
* Sets value of script struct based on imported string
*
* @param Buffer String to read text data out of
* @param Value Struct that will be modified
* @param OwnerObject UObject that contains this struct
* @param PortFlags EPropertyPortFlags controlling import behavior
* @param ErrorText What to print import errors to
* @param StructName Name of struct, used in error display
* @param bAllowNativeOverride If true, will try to run native version of export text on the struct
* @return Buffer after parsing has succeeded, or NULL on failure
*/
COREUOBJECT_API const TCHAR* ImportText(const TCHAR* Buffer, void* Value, UObject* OwnerObject, int32 PortFlags, FOutputDevice* ErrorText, const FString& StructName, bool bAllowNativeOverride = true);
and here is my code:
UFUNCTION(BlueprintCallable, Category = "ReflectionSystem|Variables")
static int SetMembersOfStructVariable(UObject * Target, FString varname, FString valueString, TArray<FStructMembers>& structProperties, FString& fullDesc)
{
if (varname.Equals("AttachmentReplication"))
return -22;
const UStruct* Owner = Target->GetClass();
UProperty* prop = Owner->PropertyLink;
const FName PropertyName(*varname);
prop = FindField<UProperty>(Owner, PropertyName);
UStructProperty* objectProp = FindField<UStructProperty>(Owner, PropertyName);
if( (objectProp != nullptr) && (prop != nullptr) )
{
FReflectionSystemBFLOutputDevice2 SaveErrors;
if (prop->GetClass() == UStructProperty::StaticClass())
{
int32 PortFlags = 0;
objectProp->Struct->ImportText(*valueString, prop, Target, PortFlags, &SaveErrors, objectProp->GetName(), true);
}
}
return 1;
}
using breakpoints, i have tested that ImportText() does it work fine. without any exception or error.
but 2/3 second later ue4 just crashes.
in between that 2/3 second if i try to print that variable then again it crashes inside:
void UObject::execInstanceVariable(FFrame& Stack, RESULT_DECL)
{
}
the error is:
Exception thrown at 0x00007FFA4CABC917
(UE4Editor-CoreUObject.dll) in
UE4Editor.exe: 0xC0000005: Access
violation reading location
0xFFFFFFFFFFFFFFFF.