diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 1e73e040c1..b7f8177a6f 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -566,7 +566,7 @@ bool wxNotebook::DeleteAllPages() bool wxNotebook::DeletePage( size_t page ) { - if ( m_selection == (int)m_pagesData.GetCount() - 1 ) + if ( m_selection >= page ) { // the index will become invalid after the page is deleted m_selection = -1; diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 1e73e040c1..b7f8177a6f 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -566,7 +566,7 @@ bool wxNotebook::DeleteAllPages() bool wxNotebook::DeletePage( size_t page ) { - if ( m_selection == (int)m_pagesData.GetCount() - 1 ) + if ( m_selection >= page ) { // the index will become invalid after the page is deleted m_selection = -1;