I found a lot of “const FSTring& Str = XXX.GetText().ToString();” in the engine, for example
FReply SSuggestionTextBox::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& KeyEvent )
{
const FString& InputTextStr = TextBox->GetText().ToString();
- The GetText() function declaration is FText GetText(), which may return either temporary or member variables
2.ToString() is declared as const FString& FText::ToString() const
GetText().ToString() can cause problems accessing the address of temporary variables, and temporary variable destructions can cause the address to become an illegal value.