Debug MainWindow pointers and casts

This commit is contained in:
Loic Guegan 2023-01-13 10:52:11 +01:00
parent f754a93f9f
commit 79cf6b2634

View file

@ -65,7 +65,7 @@ MainWindow::MainWindow()
void MainWindow::OnAuiNotebookPageCheck(wxAuiNotebookEvent& event){ void MainWindow::OnAuiNotebookPageCheck(wxAuiNotebookEvent& event){
int selection=event.GetSelection(); int selection=event.GetSelection();
TabInfos *t=dynamic_cast<TabInfos *>(notebook->GetPage(selection)); TabInfos *t=(TabInfos*)notebook->GetPage(selection)->GetClientData();
if(t->is_dirty){ if(t->is_dirty){
wxMessageDialog *dial = new wxMessageDialog(NULL, wxMessageDialog *dial = new wxMessageDialog(NULL,
wxT("This tab contains data that are not saved. Are you sure you want to close it?"), wxT("Information"), 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() { void MainWindow::ApplyPreferences() {
for (int i = 0; i < notebook->GetPageCount(); i++) { for (int i = 0; i < notebook->GetPageCount(); i++) {
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetPage(i)); TabInfos *infos = (TabInfos*)(notebook->GetPage(i))->GetClientData();
infos->ApplyPreferences(); infos->ApplyPreferences();
} }
} }
@ -245,7 +245,7 @@ void MainWindow::NewGame(bool useFen) {
} }
void MainWindow::OnPageChange(wxAuiNotebookEvent &event) { void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetCurrentPage()); TabInfos *infos = (TabInfos*)(notebook->GetCurrentPage())->GetClientData();
if (infos->type != TabInfos::GAME) { if (infos->type != TabInfos::GAME) {
for (short i = 10; i < 20; i++) { for (short i = 10; i < 20; i++) {
if (menu_game->FindChildItem(i) != NULL) { if (menu_game->FindChildItem(i) != NULL) {
@ -256,7 +256,7 @@ void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
} }
void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) { void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) {
GameTab *win = (GameTab*)event.GetEventObject(); wxWindow *win = (wxWindow*)event.GetEventObject();
int page = notebook->GetPageIndex(win); int page = notebook->GetPageIndex(win);
if (page != wxNOT_FOUND) { if (page != wxNOT_FOUND) {
notebook->SetPageText(page, win->GetLabel()); notebook->SetPageText(page, win->GetLabel());