Fix majors memory leaks (TODO: shared_ptr for Game objects and implement ~Game())

This commit is contained in:
Loic Guegan 2022-02-28 18:51:47 +01:00
parent 8f1e8fa106
commit a8c59c41bc
12 changed files with 40 additions and 4 deletions

View file

@ -30,7 +30,7 @@ EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
}
EngineTab::EngineTab(wxWindow *parent, std::string name)
: TabEngine(parent), TabInfos(TabInfos::ENGINE) {
: TabEngine(parent), TabInfos(TabInfos::ENGINE), engine(NULL) {
SetLabel(name);
engineName = name;
confGroup = "engines/" + engineName;
@ -44,6 +44,14 @@ EngineTab::EngineTab(wxWindow *parent, std::string name)
Bind(wxEVT_BUTTON, &EngineTab::OnDelete, this, ENGINE_DELETE_CONF_BUTTON);
}
EngineTab::~EngineTab() {
if (engine != NULL) {
wxLogDebug("EngineTab destructor: destroying engine!");
engine->quit();
delete engine;
}
}
void EngineTab::OnDelete(wxCommandEvent &event) {
CONFIG_OPEN(conf);
conf->DeleteGroup(confGroup);

View file

@ -16,6 +16,7 @@ public:
EngineTab(wxWindow *parent, uciadapter::UCI *engine,
std::string engine_path_or_name);
EngineTab(wxWindow *parent, std::string name);
~EngineTab();
void ApplyPreferences() {}
void *GetGame() { return (NULL); }
void *GetBase() { return (NULL); }