You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This was a tough one to track down. The problem showed up when closing a matinee editor whilst a preview camera was selected in the world. Several clients all hook into the EditorModeChanged event to do some cleanup when the matinee editor is closed. When matinee was closed, it fired the event to say that the mode is changing. This broadcast took a copy of the invocation list, and proceeded to invoke each delegate. One of these handlers resulted in the preview actor being deleted, which ended up deleting its associated preview viewport. As part of the viewport's destructor it correctly removes its raw ptr from the mode changing delegate list. However, since this event is currently broadcasting, a copy of the delegate still exists in the local invocation list which is invoked later on. The trouble is, the user object has been destroyed by this time. I have fixed this by moving the destruction of the preview actor to a subsequent event triggered when the matinee mode is exited. This is invoked immediately after the OnEditorModeChanged event, and fixes the issue because it waits until the first broadcast to finish before destroying the viewport. The alternative would have been to make FEditorViewportClient derive from TSharedFromThis<> and use AddSP for its binding, but I don't think that publicizing the sharing of viewport clients is the right approach. I'd rather keep ownership of viewport clients more explicit. Reviewed by Thomas.Sarkanen, Matt Kuhlenschmidt [CL 2061973 by Andrew Rodham in Main branch]