Hey all,
I’m having an issue from getting a TSharedPtr
to a normal FString to use in Slate.
Issue is as following:
I have a SComboBox>
which has a .OnGenerateWidget()
and .OptionsSource()
, from a TArray
i build the TArray>
for the Combobox, refresh options(doesn’t crash on this point) and then when i click the SComboBox in the editor it breaks with error “Ran out of memory allocating 18446744073709551612 bytes with alignment 0”. Assuming it runs the binded OnGenerateWidget() when we click the SComboBox it crashes whenever I try to get the TSharedPtr
to an FString
.
The line it crashes at is “FString stringname = *InItem;”
I tried the following combos
FString stringname = **InItem; (Access violation)
FString stringname = *InItem.Get(); (Out of memory)
FString stringname = *InItem; (Out of memory)
Anyone any idea what i’m doing wrong here?
Slate code:
SNew(SBox).WidthOverride(150.0f).HAlign(HAlign_Left)
[
SAssignNew(WorkspaceCombo, SComboBox<TSharedPtr<FString>>)
.OnGenerateWidget(this, &STogglWidget::GenerateProjects)
.OptionsSource(&WorkspaceArray)
]
Functions->
TSharedRef<SWidget> STogglWidget::GenerateProjects(TSharedPtr<FString> InItem)
{
if (InItem.IsValid())
{
FString stringname = *InItem;
UE_LOG(LogTemp, Error, TEXT("%s"), *stringname);
}
return SNew(STextBlock);
}
void STogglWidget::UpdateWorkspaces(TArray<FString> Workspaces) {
WorkspaceArray.Empty();
for (FString Workspace : Workspaces)
{
WorkspaceArray.Add(MakeShareable<FString>(&Workspace));
UE_LOG(LogTemp, Error, TEXT("%s"), **WorkspaceArray[0].Get());
}
WorkspaceCombo->RefreshOptions();
}