diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-28 18:51:47 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-28 18:51:47 +0100 |
| commit | a8c59c41bc103f0336d9982369be5dd85ac68111 (patch) | |
| tree | fb6bfea03fe6b000fc7f3c4a0421388cd6a13d57 /src/game_tab | |
| parent | 8f1e8fa106107c61c7ac62fa0f13340537ba4d23 (diff) | |
Fix majors memory leaks (TODO: shared_ptr for Game objects and implement ~Game())
Diffstat (limited to 'src/game_tab')
| -rw-r--r-- | src/game_tab/left_panel/board/BoardCanvas.cpp | 5 | ||||
| -rw-r--r-- | src/game_tab/left_panel/board/BoardCanvas.hpp | 1 | ||||
| -rw-r--r-- | src/game_tab/right_panel/LiveEngineDialog.cpp | 10 | ||||
| -rw-r--r-- | src/game_tab/right_panel/LiveEngineDialog.hpp | 1 |
4 files changed, 15 insertions, 2 deletions
diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index 237a68a..4b5f3fb 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -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) { diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 34c4911..83c960a 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -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); diff --git a/src/game_tab/right_panel/LiveEngineDialog.cpp b/src/game_tab/right_panel/LiveEngineDialog.cpp index 1f509ae..73d3eb3 100644 --- a/src/game_tab/right_panel/LiveEngineDialog.cpp +++ b/src/game_tab/right_panel/LiveEngineDialog.cpp @@ -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) { diff --git a/src/game_tab/right_panel/LiveEngineDialog.hpp b/src/game_tab/right_panel/LiveEngineDialog.hpp index 999002f..0996ba0 100644 --- a/src/game_tab/right_panel/LiveEngineDialog.hpp +++ b/src/game_tab/right_panel/LiveEngineDialog.hpp @@ -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); |
