Is the StarrtHerePage:: htmlWindow being leaked because it is never Destroy()ed?
In startherepage.cpp line 66 the htmlWindow is allocated:
StartHerePage::StartHerePage(wxEvtHandler* owner, wxWindow* parent)
: EditorBase(parent, g_StartHereTitle),
m_pOwner(owner)
{
//ctor
wxBoxSizer* bs = new wxBoxSizer(wxVERTICAL);
wxString resPath = ConfigManager::ReadDataPath();
m_pWin = new MyHtmlWin(this, idWin, wxPoint(0,0), GetSize());
But the htmlWindow is *not* destroyed because the code is commented out:
startherepage.cpp line 133
startherepage.cpp 133
StartHerePage::~StartHerePage()
{
//dtor
//m_pWin->Destroy();
}
The StartHerePage itself *is* destroyed at:
main.cpp lines 1760 & 1772
void MainFrame::ShowHideStartPage(bool forceHasProject)
{
if (Manager::IsBatchBuild())
return;
// we use the 'forceHasProject' param because when a project is opened
// the EVT_PROJECT_OPEN event is fired *before* ProjectManager::GetProjects()
// and ProjectManager::GetActiveProject() are updated...
if(m_InitiatedShutdown)
{
EditorBase* sh = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
if (sh)
sh->Destroy();
return;
}
bool show = !forceHasProject &&
Manager::Get()->GetProjectManager()->GetProjects()->GetCount() == 0 &&
Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/start_here_page"), true);
EditorBase* sh = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
if (show && !sh)
sh = new StartHerePage(this, Manager::Get()->GetEditorManager()->GetNotebook());
else if (!show && sh)
sh->Destroy();
}
Any other referenced to m_pWin are:
src\startherepage.cpp|66|m_pWin = new MyHtmlWin(this, idWin, wxPoint(0,0), GetSize());|
src\startherepage.cpp|79|m_pWin->SetFonts(wxEmptyString, wxEmptyString, &sizes[0]);|
src\startherepage.cpp|82|m_pWin->LoadPage(resPath + _T("/start_here.zip#zip:start_here.html"));|
src\startherepage.cpp|120|m_pWin->SetPage(buf);|
src\startherepage.cpp|125|bs->Add(m_pWin, 1, wxEXPAND);|
src\startherepage.cpp|133|//m_pWin->Destroy();|
src\startherepage.cpp|152|m_pWin->SetPage(buffer);|
src\startherepage.h|33|wxHtmlWindow* m_pWin;|
I put a trap in wxEVT_CREATE to catch the address of the htmlWindow.
I put another trap in wxEVT_DESTROY to try and catch it's destruction.
It never happened.
I then enable the "m_pWin->Destroy()" statement for a week. It seem to work fine, and the trap in my wxEVT_DESTROY saw it.
What am I missing?