Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Bug: Memory leak at NewFromTemplateDlg::NewFromTemplateDlg
(1/1)
lights_joy:
I'm now using c::b 13.12, there is a bug at NewFromTemplateDlg::NewFromTemplateDlg
--- Code: ---NewFromTemplateDlg::NewFromTemplateDlg(TemplateOutputType initial, const wxArrayString& user_templates)
: m_Template(nullptr),
m_pWizard(nullptr),
m_WizardIndex(-1)
{
//ctor
wxXmlResource::Get()->LoadObject(this, nullptr, _T("dlgNewFromTemplate"),_T("wxScrollingDialog"));
m_Wizards = Manager::Get()->GetPluginManager()->GetOffersFor(ptWizard);
wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
SetSettingsIconsStyle(lb->GetListView(), sisNoIcons);
// create image lists
XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
// load view prefs
XRCCTRL(*this, "rbView", wxRadioBox)->SetSelection(Manager::Get()->GetConfigManager(_T("new_from_template"))->ReadInt(_T("/view"), 0));
ChangeView();
BuildCategories();
BuildList();
// fill user templates list
XRCCTRL(*this, "lstUser", wxListBox)->Clear();
for (unsigned int i = 0; i < user_templates.GetCount(); ++i)
{
XRCCTRL(*this, "lstUser", wxListBox)->Append(user_templates[i]);
}
lb->SetSelection((int)initial);
}
--- End code ---
in the constructor, it allocates 8 ImageList, but in the destructor, it only free 4 Image List, so there is a memory leak!!
--- Code: ---NewFromTemplateDlg::~NewFromTemplateDlg()
{
//dtor
delete XRCCTRL(*this, "listProjects", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
delete XRCCTRL(*this, "listTargets", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
delete XRCCTRL(*this, "listFiles", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
delete XRCCTRL(*this, "listCustoms", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
ClearList();
}
--- End code ---
oBFusCATed:
Fixed in SVN HEAD, thanks for reporting it.
Navigation
[0] Message Index
Go to full version