From 2d9730e216976103daea64a8df047d5f0dffd5f7 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 24 Dec 2022 12:46:59 +0100 Subject: Update tab management system --- 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 2243f86..8b6e0fe 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -191,9 +191,9 @@ void MainWindow::NewGame(bool useFen) { } void MainWindow::OnNewGame(wxCommandEvent &event) { - std::shared_ptr *g = (std::shared_ptr*)event.GetClientData(); - NewGame(*g); - delete g; + TabInfos *tab = (TabInfos*)event.GetClientData(); + TabInfos *i=NewGame(tab->GetGame()); + i->Link(tab); } void MainWindow::OnPageChange(wxAuiNotebookEvent &event) { @@ -215,8 +215,9 @@ void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) { } } -void MainWindow::NewGame(std::shared_ptr game) { +TabInfos* MainWindow::NewGame(std::shared_ptr game) { GameTab *gt = new GameTab((wxFrame *)notebook, game); notebook->AddPage(gt, gt->GetLabel()); notebook->SetSelection(notebook->GetPageIndex(gt)); + return(gt); } -- cgit v1.2.3