The main thing I’m wondering is, let’s say a button’s action causes itself to be deleted. By this I mean, an action listener has been added to the button, and that action event would like for the button to be destroyed when it is called. But it can’t just call delete on it, it needs to some how mark it for deleting and when the button is done its event, it gets deleted.
For me there are 2 main issues here: Because my GUI is polymorphic, the pointer could have come from a factory in a DLL. Also, even if I added the button to a delete queue, when should that queue be dequeued? Should I just check the queue each time my game gets an update()?
How is this usually done in GUIs where you can for example create a SuperButton from BaseButton.
Thanks
Usually in a GUI there is a message loop for handling asynchronous input messages. Assuming you have such a thing, the normal approach is to post a message to this queue which will result in the control being deleted. Because the message queue is pumped after your event handler completes you have no problems.