From 79cf6b2634eaa3cf3ff67d875847b6934a48a911 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 13 Jan 2023 10:52:11 +0100 Subject: [PATCH] Debug MainWindow pointers and casts --- src/MainWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index e379319..21e0a92 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -65,7 +65,7 @@ MainWindow::MainWindow() void MainWindow::OnAuiNotebookPageCheck(wxAuiNotebookEvent& event){ int selection=event.GetSelection(); - TabInfos *t=dynamic_cast(notebook->GetPage(selection)); + TabInfos *t=(TabInfos*)notebook->GetPage(selection)->GetClientData(); if(t->is_dirty){ wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("This tab contains data that are not saved. Are you sure you want to close it?"), wxT("Information"), @@ -215,7 +215,7 @@ void MainWindow::OpenSettings() { void MainWindow::ApplyPreferences() { for (int i = 0; i < notebook->GetPageCount(); i++) { - TabInfos *infos = dynamic_cast(notebook->GetPage(i)); + TabInfos *infos = (TabInfos*)(notebook->GetPage(i))->GetClientData(); infos->ApplyPreferences(); } } @@ -245,7 +245,7 @@ void MainWindow::NewGame(bool useFen) { } void MainWindow::OnPageChange(wxAuiNotebookEvent &event) { - TabInfos *infos = dynamic_cast(notebook->GetCurrentPage()); + TabInfos *infos = (TabInfos*)(notebook->GetCurrentPage())->GetClientData(); if (infos->type != TabInfos::GAME) { for (short i = 10; i < 20; i++) { if (menu_game->FindChildItem(i) != NULL) { @@ -256,7 +256,7 @@ void MainWindow::OnPageChange(wxAuiNotebookEvent &event) { } void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) { - GameTab *win = (GameTab*)event.GetEventObject(); + wxWindow *win = (wxWindow*)event.GetEventObject(); int page = notebook->GetPageIndex(win); if (page != wxNOT_FOUND) { notebook->SetPageText(page, win->GetLabel());