If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
1. m_savedChangesTextHideTimer = new wxTimer(this);
2. m_savedChangesTextHideTimer->StartOnce(TEN_SECONDS);
3.
if (m_savedChangesTextHideTimer->IsRunning()
{
m_savedChangesTextHideTimer->Stop();
}
Does anything else needs to be done?
Because when i attach a memory leak detector to the application, it shows leaks on the line where it is created.
Any help is very much appreciated.
Thank for for your replies @PB and @Kvaz1r.
I have not deleted the timer at all. Ofcourse there is no need to create it with a new. It can be a static instance too.
But that is how ALL other wxWidgets objects in our application are created - using new, so did that with the timer as well.
We don't delete any other wxWidget instance created using new. Any reason why it needs to be done with wxTimer?
deepti wrote: ↑Mon Nov 18, 2019 11:15 am
We don't delete any other wxWidget instance created using new. Any reason why it needs to be done with wxTimer?
The only wxWidgets new()ed variables that are not to be deleted (manually) are wxWindows and wxSizer(Item)s (except modal dialogs, but these should be created on the stack anyway). Anything else (e.g., wxString, wxTimer, wxColour, wxFFile, wxDateTime, wxVariant, ) must be somehow (manually, using a smart pointer) deleted.
deepti wrote: ↑Mon Nov 18, 2019 11:55 am
@PB, how about wxButton, wxStaticText, wxTextCtrl etc, created using new? They need to be deleted too ?
all this controls have "parent" in their constructor parameters list. at destruction, the parent recursively deletes all childs(where childs delete their childs).
so if you provided a parent to such a window - parent will delete them at his deletion.
but if you provided a null parent - then you must delete it manually.