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

@ -14,6 +14,11 @@ BoardCanvas::BoardCanvas(wxFrame *parent)
ApplyPreferences();
}
BoardCanvas::~BoardCanvas() {
delete t;
delete t_captures;
}
BoardCanvas::BoardCanvas(wxFrame *parent, std::uint32_t square_width,
bool frozen)
: BoardCanvas(parent) {

View file

@ -54,6 +54,7 @@ class BoardCanvas : public wxPanel {
public:
BoardCanvas(wxFrame *parent);
BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen);
~BoardCanvas();
void ApplyPreferences();
void DrawBoard(wxPaintDC &dc);
void OnPaint(wxPaintEvent &event);

View file

@ -13,6 +13,13 @@ LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name)
Bind(wxEVT_CLOSE_WINDOW, &LiveEngineDialog::OnClose, this);
}
LiveEngineDialog::~LiveEngineDialog() {
if (engine != NULL) {
wxLogDebug("LiveEngineDialog destructor: delete engine");
delete engine;
}
}
void LiveEngineDialog::InitEngine() {
if (engine == NULL) {
wxLogDebug("Start engine: %s", engine_name);
@ -51,9 +58,8 @@ void LiveEngineDialog::OnClose(wxCloseEvent &e) {
timer.Stop();
engine->stop();
engine->quit();
delete engine;
}
e.Skip();
Destroy();
}
void LiveEngineDialog::SetFEN(std::string fen) {

View file

@ -10,6 +10,7 @@ class LiveEngineDialog : public DialogLiveEngine {
public:
LiveEngineDialog(wxWindow *parent, std::string engine_name);
~LiveEngineDialog();
void InitEngine();
void TogglePauseEngine(wxCommandEvent &event);
void OnTimerTick(wxTimerEvent &event);