Migrate to std::shared_ptr<Game>

This commit is contained in:
Loic Guegan 2022-02-28 20:16:57 +01:00
parent 4c959fe12e
commit 44ea0a50a3
16 changed files with 44 additions and 49 deletions

View file

@ -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));