From 44ea0a50a39d58cb9e1f167c2973e396b4d853aa Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 28 Feb 2022 20:16:57 +0100 Subject: Migrate to std::shared_ptr --- src/MainWindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/MainWindow.cpp') diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7078076..a9e720d 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -52,7 +52,7 @@ MainWindow::MainWindow() Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY); // Add new game tab by default - NewGame(new Game()); + NewGame(std::shared_ptr(new Game())); } void MainWindow::OnCloseTabEvent(wxCommandEvent &event) { @@ -191,8 +191,9 @@ void MainWindow::NewGame(bool useFen) { } void MainWindow::OnNewGame(wxCommandEvent &event) { - Game *g = (Game *)event.GetClientData(); - NewGame(g); + std::shared_ptr *g = (std::shared_ptr*)event.GetClientData(); + NewGame(*g); + delete g; } void MainWindow::OnPageChange(wxAuiNotebookEvent &event) { @@ -214,7 +215,7 @@ void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) { } } -void MainWindow::NewGame(Game *game) { +void MainWindow::NewGame(std::shared_ptr game) { GameTab *gt = new GameTab((wxFrame *)notebook, game); notebook->AddPage(gt, gt->GetLabel()); notebook->SetSelection(notebook->GetPageIndex(gt)); -- cgit v1.2.3