Normally when I delete an object I set it to zero. This helps in that I code my routines to check the object is not zero then proceed.
However if I use the deleteLater()
function I have lost control of it. I don't know if its a valid item or if I need to create a new one. The solution I found was just to keep track of the state separately however is there a better way?
There is nothing wrong if you call deleteLater()
on your object and then set your pointer to nullptr
. Qt framework will safely delete the object for you.
As an alternative you can also connect to destroyed signal to be notified of your object's destruction and set your pointer to nullptr
in that slot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With