diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-28 20:16:57 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-28 20:16:57 +0100 |
| commit | 44ea0a50a39d58cb9e1f167c2973e396b4d853aa (patch) | |
| tree | 14cae56496eb72816f6f3d8b2323e6abfa79f200 /src/MainWindow.cpp | |
| parent | 4c959fe12ed2f26cbfac9646d3488cb00676fb31 (diff) | |
Migrate to std::shared_ptr<Game>
Diffstat (limited to 'src/MainWindow.cpp')
| -rw-r--r-- | src/MainWindow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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<Game>(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<Game> *g = (std::shared_ptr<Game>*)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> game) { GameTab *gt = new GameTab((wxFrame *)notebook, game); notebook->AddPage(gt, gt->GetLabel()); notebook->SetSelection(notebook->GetPageIndex(gt)); |
