Hey,
I try to add a simple SListView with FString-content to a new window which I create with a plugin.
Unfortunately after two days searching in the UE4-sourcecode I still can’t get a window with a simple listview working.
Part where the SWidget is created which should be added to the window:
TSharedRef<SWidget> windowContent = SNew(SBox)
.MaxDesiredHeight(512)
.MaxDesiredWidth(512)
.Content()
[
SAssignNew(listView, SListView<TSharedPtr<FString>>)
.ListItemsSource(&presetList)
.OnGenerateRow(this, &FImportLayers::GeneratePresetListRow)
.SelectionMode(ESelectionMode::Single)
];
Window->SetContent(windowContent);
My OnGenerateRow-function:
TSharedRef<ITableRow> FImportLayers::GeneratePresetListRow(TSharedPtr<FString> InItem, const TSharedRef<STableViewBase>& OwnerTable)
{
return
SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
[
SNew(STextBlock).Text(FText::FromString(*InItem))
];
}
This is the crash error when the SWidget should be created:
Unknown exception - code 00000001 (first/second chance not available)
Assertion failed: SharedThis.Get() == this [File:XXX\UnrealEngine\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1012]
KERNELBASE + 37901 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [XXX\unrealengine\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FOutputDevice::Logf__VA() + 248 bytes [XXX\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:144]
UE4Editor_Core!FDebug::AssertFailed() + 1079 bytes [XXX\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:224]
UE4Editor_ImportLayers!TSharedFromThis<IDetailCustomization,0>::AsShared() + 120 bytes [XXX\unrealengine\engine\source\runtime\core\public\templates\sharedpointer.h:1016]
The header file to the main class:
...
class FImportLayers : public IModuleInterface, public TSharedFromThis<FImportLayers>
{
...
private:
...
TSharedRef<ITableRow> GeneratePresetListRow(TSharedPtr<FString> InItem, const TSharedRef<STableViewBase>& OwnerTable);
TSharedPtr<SListView<TSharedPtr<FString>>> listView;
TArray<TSharedPtr<FString>> presetList;
};
Do you have any idea why I get this crash? As far as I know I used exactly the same code like it is used in all the examples in the UE source.
Thanks for your help.
EDIT: It’s not directly related with the SListView. Now I tried another way with a SButton. Adding the SButton works fine, until I try to add the onClicked-function. With the OnClicked-function I get the same crash again. So it seems to related to the Delegates. Right?