TSharedPtr to Fstring out of memory

User “Turfster” on Discord found the solution.

This line

WorkspaceArray.Add(MakeShareable<FString>(&Workspace));

is using the temporary FString “Workspace” of the for each loop.
The passed memory address is valid INSIDE of the UpdateWorkspaces function, but when used later in the GenerateProjects function (called by the SComboBox for each entry of the WorkspaceArray) the address is invalid, because the original FString is long gone.

The solution for this is creating a new FString and just passing it the value of the Workspace FString like this:

WorkspaceArray.Add(MakeShareable<FString>(new FString(Workspace)));