deleteLater on a member
This is probably a stupid question:
I have a class with a member progress dialog.
Whenever I activate a download process the class will spawn that dialog.
I don't want the dialog to linger between downloads, so I close it when the download was finished and also use deleteLater();
Now to my question:
Will the old dialog be properly deleted if I do this at the beginning of the next download:
m_pdlg = new my_progress_dialog(...);
When calling deleteLater, the object should get deleted the next time the event loop runs.
@SGaist can you elaborate?
deleteLatermarks the object for deletion. So next time the Qt event loop runs, it will process that deletion request. This allows for anything pending on that object to be properly cleaned and then the object deleted.
@SGaist so I just tested with either "m_pdlg->deleteLater()" and "delete m_pdlg" and in both cases the pointer was not a nullptr afterwards (at the beginning of the next download process before using "m_pdlg = new ..."). Is that normal?
Yes it is, raw pointers don't reset themselves to zero.
@SGaist Thank you. I think I can work with that