Correct way to delete a window

Hello, I am having a few issues with freeing windows.

The problem is that when I use DocumentWindow::closeButtonPressed it is a virtual function call.

So if I would delete the window in that callback, I would be basically deleting the this pointer of the virtual function currently running.

Is there something like a dispatcher that can be used for this?


Have a look at the docs for that function:

... using 'delete this' is in fact a typical suggested thing to do here!

As long as you know the object isn't going to be directly used afterwards, then calling 'delete this' is safe (even in a virtual function).

If you're actually having a problem, it's probably because you're doing something else too :)

Thanks, I worked around this for now with a timer that handles all windows that need to be deleted.

I will investigate this further later when I have more time.