MothCocoon / FlowGraph

Design-agnostic node system for scripting game’s flow in Unreal Engine
https://discord.gg/Xmtr6GhbmW
MIT License
1.21k stars 239 forks source link

Added check to prevent crash when deleting two or more node assets (if some of them are in undo history) #201

Closed MaksymKapelianovych closed 4 months ago

MaksymKapelianovych commented 5 months ago

Steps to reproduce:

  1. create two bp flow node assets
  2. place one in any flow graph
  3. delete placed node
  4. delete created assets from step 1

The reason for this is that deleted graph node are stored in undo history, so there remains memory reference to node (and asset). And if user presses "force delete", Unreal treats deletion of both assets differently (compared to the case where there are no references), eventually setting their GeneratedClass to nullptr before broadcasting OnAssetRemoved delegate. After that, UFlowGraphSchema::OnAssetRemoved triggers for every deleted asset separately (I tried to use AssetRegistry.Get().OnAssetsRemoved(), but it also broadcasts for every asset separately), and broadcasts OnNodeListChanged ... eventually UFlowGraphSchema::GetFlowNodeCategories will be called, and this is the place where first node will be already deleted from BlueprintFlowNodes array, but the second is not and the second already has GeneratedClass == nullptr.