Hey folks,
We’ve been seeing an odd crash since the 5.8 preview, that’s persisting in 5.8.0. The user toolbox appears to be unable to clean up the FSlateBrush’s stored in “BrushResources” on shutdown. It’s a strange crash because multiple programmers within our studio have had a look at it and we’re still scratching our heads. It appears like it’s failing to call the destructor for a particular FSlateBrush. From looking at the pointers we have, it looks like the crash occurs when it begins to clean up the custom icons our project adds.
The code itself, we all agree, seems fairly innocuous and it seems to be correct for every other time that it runs. It seems to just go haywire when the editor is shutting down. From breaking out the various parts of the code into single lines, we always appear to land with the debugger executing/failing to execute the delete call.
I am going to try to reduce the problem down to a sample project so that’ll hopefully be ready once Epic’s summer break is finished. I just don’t have it ready today. I still wanted to report just in case this was something known with a workaround/fix, or could start the conversation around it.
Many thanks,
David
[Attachment Removed]
Okay! I don’t have a custom project, but I do understand the crash now.
It is occurring because there’s a map containing UniquePtr’s, and the contents of that array is also being copied to a second class with a second array. That array is then looping over them to attempt to delete them after the map of UniquePtr’s has already deleted them, causing the crash.
In UserToolBoxStyle.cpp/.h there’s a static TMap<FString, TUniquePtr<FSlateImageBrush>> ExternalBrushes. In FUserToolBoxStyle::AddExternalImageBrushes there’s a line where once a brush has been found, it is used with the StyleInstance->Set(*Info.Id, FoundBrush->Get()); function. That function keeps a copy of the pointer and when it is shutting down, attempts to run a loop where those pointers are deleted.
I spotted this luckily after trying to manually call UserToolBoxStyle::Shutdown and messing around with the order in which StyleInstance and ExternalBrushes are cleaned up.
Locally I’ve converted that map to contain raw pointers, which seems to be holding together and allowing the editor to shut down cleanly. I’m assuming that all delete duties will be handled within StyleInstance’s deletion.
Many thanks,
David
[Attachment Removed]
Hi,
Sorry for the delay, looks like this ticket triaged to a different queue. I went ahead and grabbed it since it’s related to your other bug report about the UserToolbox plugin. Converting ExternalBrushes to use raw pointers looks to be the correct approach here since the lifetime is managed by the style set, I’ll get that change reviewed and submitted shortly. Thanks!
[Attachment Removed]