I have some custom C++ being called in Blueprints for a Dialogue System. All of my dialogues work fine, except for two that crash the editor after replaying a few times. I’m getting invalid memory access errors. At first I thought it might have been Interface pointers, used in function pointers, not being cleaned up correctly on shutdown. (These are used to handle changing dialogue based on gamestate) I implemented
BeginDestroy() methods to manually delete those pointers, and that just changes the stack trace when replaying.
For the dialogue system I have one UMG blueprint that displays the current dialogue, and depending on how many options the current dialogue has it creates that amount of versions of the Choice widget, and populates it with the text for that choice. Thinking that’s what isn’t being cleaned up properly. The choices get added to an array of choices that gets added to the parent vertical box, whenever a choice is made. The old values in the array get removed from the vertical box, and the array gets cleared as well.
[Stack trace without deleting interface pointer]
[Stack trace with deleting interface pointer, and clearing interface Widget]
[Stack trace of ensuring choice widget array cleared on destroy]
Blue prints responsible for removing Dialogue choices from screen:
This is on Linux, but the same issue happens on Windows as well. What’s the proper way to ensure a UMG Widget gets destroyed, after stopping play?