I am wondering what will happen if I try to delete on a pointer that has already been deleted or may not have been highlighted? I read two things: firstly, the delete will do some checks, and we don’t need to check if the pointer is null; and then, I read that this could lead to unknown behavior ..
I ask for this because I use some personal objects that contain Qt object attributes; I think Qt removes all the widgets associated with closing the window, but I'm not sure and still: if the soft fails before closing the window, we must delete all the objects manually.
So what would be the best solution? Something like that?
if( my_object ) delete my_object;
Can dangerous behavior be avoided?
source share