X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b318dc42374cfb58878c779447c9d0a6fc79eb1d..458425003481da3dde531a9677014b07070b7095:/src/gtk1/notebook.cpp diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index fe5e541720..33aa5ab39d 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -20,6 +20,7 @@ #include "wx/imaglist.h" #include "wx/intl.h" #include "wx/log.h" +#include "wx/bitmap.h" #include "wx/gtk/private.h" #include "wx/gtk/win_gtk.h" @@ -86,14 +87,12 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget), gint page, wxNotebook *notebook ) { - static bool s_inPageChange = FALSE; - // are you trying to call SetSelection() from a notebook event handler? // you shouldn't! - wxCHECK_RET( !s_inPageChange, + wxCHECK_RET( !notebook->m_inSwitchPage, _T("gtk_notebook_page_change_callback reentered") ); - s_inPageChange = TRUE; + notebook->m_inSwitchPage = TRUE; if (g_isIdle) wxapp_install_idle_handler(); @@ -123,7 +122,7 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget), notebook->GetEventHandler()->ProcessEvent( eventChanged ); } - s_inPageChange = FALSE; + notebook->m_inSwitchPage = FALSE; } //----------------------------------------------------------------------------- @@ -190,6 +189,8 @@ static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) { int sel = win->GetSelection(); + if (sel == -1) + return TRUE; wxGtkNotebookPage *nb_page = win->GetNotebookPage(sel); wxCHECK_MSG( nb_page, FALSE, _T("invalid selection in wxNotebook") ); @@ -236,8 +237,9 @@ END_EVENT_TABLE() void wxNotebook::Init() { m_padding = 0; + m_inSwitchPage = FALSE; + m_imageList = (wxImageList *) NULL; - m_pagesData.DeleteContents( TRUE ); m_selection = -1; m_themeEnabled = TRUE; } @@ -370,7 +372,7 @@ int wxNotebook::SetSelection( int page ) { wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") ); - wxCHECK_MSG( page < (int)m_pagesData.GetCount(), -1, wxT("invalid notebook index") ); + wxCHECK_MSG( page >= 0 && page < (int)m_pagesData.GetCount(), -1, wxT("invalid notebook index") ); int selOld = GetSelection(); @@ -564,7 +566,9 @@ wxNotebookPage *wxNotebook::DoRemovePage( int page ) gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page ); - m_pagesData.DeleteObject(GetNotebookPage(page)); + wxGtkNotebookPage* p = GetNotebookPage(page); + m_pagesData.DeleteObject(p); + delete p; return client; }