Issues using SListView

Hello,

I am having issues with using SListView.

The Error is being thrown here.


SAssignNew(ListView, SListView<TSharedPtr<FData>>)
		.SelectionMode(ESelectionMode::Single)
		.ItemHeight(24.0f)
		.ListItemsSource(&Data)
		.OnGenerateRow(this, &SNewTab::OnGenerateNewRow)
		;

I am trying to make a new tab in the engine and I created an SWidget class for the view, and I wanted to use an SListView. And I wanted a SButton to create more items. However there have been a few issues:

  1. When there is nothing in the “Data” Array and I try to add items the ListView won’t do anything.
  2. When I have 1 items predefined in the “Data” Array the tab opens fine but if I try to add another item via SButton clicked Event the editor will crash.
  3. When I have 2 or more items int the “Data” Array the Editor will crash upon the tab opening.

The error seems to be with a TArray =operator (according to the breakpoint) am I suppose to do something specfic with the TArray like set a MaxSize or something?

Sorry if I am doing something obvious, I’m new to coding in the engine.

Thanks for the help!

TL;DR When I use SListView I can’t have more than 1 elements or the editor crashes

Can’t help you with the crashes without a callstack, but when the item collection changes, you have to notify the list view via its RequestListRefresh method.

I actually completely forgot to run RequestListRefresh. Thanks for that, however I am still having issues with the Array.

Here is the call stack.
Thanks for your help!

> UE4Editor-Core.dll!TArray<wchar_t,FDefaultAllocator>::operator=(const TArray<wchar_t,FDefaultAllocator> & Other) Line 419 C++
UE4Editor-Core.dll!FString::operator=(const FString & __that) Line 1700 C++
UE4Editor-Kismet.dll!SBlueprintAlternatives::AddAlternative() Line 200 C++
UE4Editor-Kismet.dll!SBlueprintAlternatives::SaveAlternative() Line 234 C++
UE4Editor-Kismet.dll!TMemberFunctionCaller<SBlueprintAlternatives,FReply (__cdecl SBlueprintAlternatives::)(void) __ptr64>::operator()<>() Line 165 C++
UE4Editor-Kismet.dll!TTupleImpl<TIntegerSequence<unsigned int> >::ApplyAfter<TMemberFunctionCaller<SBlueprintAlternatives,FReply (__cdecl SBlueprintAlternatives::
)(void) __ptr64> >(TMemberFunctionCaller<SBlueprintAlternatives,FReply (__cdecl SBlueprintAlternatives::*)(void)> && Func) Line 134 C++
UE4Editor-Kismet.dll!TBaseSPMethodDelegateInstance<0,SBlueprintAlternatives,0,FReply __cdecl(void)>::Execute() Line 327 C++
UE4Editor-Slate.dll!TBaseDelegate<FReply>::Execute() Line 537 C++
UE4Editor-Slate.dll!SButton::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) Line 278 C++
UE4Editor-Slate.dll!FSlateApplication::RoutePointerUpEvent::__l8::<lambda>(const FArrangedWidget & TargetWidget, const FPointerEvent & Event) Line 5075 C++
UE4Editor-Slate.dll!FEventRouter::Route<FReply,FEventRouter::FToLeafmostPolicy,FPointerEvent,FReply <lambda>(const FArrangedWidget &, const FPointerEvent &) >(FSlateApplication * ThisApplication, FEventRouter::FToLeafmostPolicy RoutingPolicy, FPointerEvent EventCopy, const FSlateApplication::RoutePointerUpEvent::l8::FReply <lambda>(const FArrangedWidget &, const FPointerEvent &) & Lambda) Line 238 C++
UE4Editor-Slate.dll!FSlateApplication::RoutePointerUpEvent(FWidgetPath & WidgetsUnderPointer, FPointerEvent & PointerEvent) Line 5064 C++
UE4Editor-Slate.dll!FSlateApplication::ProcessMouseButtonUpEvent(FPointerEvent & MouseEvent) Line 5531 C++
UE4Editor-Slate.dll!FSlateApplication::OnMouseUp(const EMouseButtons::Type Button, const FVector2D CursorPos) Line 5508 C++
UE4Editor-Core.dll!FWindowsApplication::ProcessDeferredMessage(const FDeferredWindowsMessage & DeferredMessage) Line 1698 C++
UE4Editor-Core.dll!FWindowsApplication::DeferMessage(TSharedPtr<FWindowsWindow,0> & NativeWindow, HWND
* InHWnd, unsigned int InMessage, unsigned int64 InWParam, int64 InLParam, int MouseX, int MouseY, unsigned int RawInputFlags) Line 2120 C++
UE4Editor-Core.dll!FWindowsApplication::ProcessMessage(HWND
* hwnd, unsigned int msg, unsigned int64 wParam, int64 lParam) Line 867 C++
UE4Editor-Core.dll!FWindowsApplication::AppWndProc(HWND
* hwnd, unsigned int msg, unsigned int64 wParam, int64 lParam) Line 714 C++
[External Code]
[Inline Frame] UE4Editor-Core.dll!WinPumpMessages() Line 957 C++
UE4Editor-Core.dll!FWindowsPlatformMisc::PumpMessages(bool bFromMainLoop) Line 980 C++
UE4Editor.exe!FEngineLoop::Tick() Line 2977 C++
[Inline Frame] UE4Editor.exe!EngineTick() C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE
* hInInstance, HINSTANCE
* hPrevInstance, int nCmdShow) Line 166 C++
UE4Editor.exe!WinMain(HINSTANCE
* hInInstance, HINSTANCE
* hPrevInstance, char * __formal, int nCmdShow) Line 199 C++
[External Code]