Reset wxAuiNotebook selection to wxNOT_FOUND if it becomes empty.
The selection was 0 in a notebook without any pages which was wrong as it must always be less than the page count. Fix this in wxAuiNotebook itself and add an assert checking for this invariant to the sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63642 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -152,6 +152,7 @@ private:
|
||||
void OnCustomizeToolbar(wxCommandEvent& evt);
|
||||
void OnAllowNotebookDnD(wxAuiNotebookEvent& evt);
|
||||
void OnNotebookPageClose(wxAuiNotebookEvent& evt);
|
||||
void OnNotebookPageClosed(wxAuiNotebookEvent& evt);
|
||||
void OnExit(wxCommandEvent& evt);
|
||||
void OnAbout(wxCommandEvent& evt);
|
||||
void OnTabAlignment(wxCommandEvent &evt);
|
||||
@@ -649,6 +650,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_AUI_PANE_CLOSE(MyFrame::OnPaneClose)
|
||||
EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, MyFrame::OnAllowNotebookDnD)
|
||||
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, MyFrame::OnNotebookPageClose)
|
||||
EVT_AUINOTEBOOK_PAGE_CLOSED(wxID_ANY, MyFrame::OnNotebookPageClosed)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@@ -1325,6 +1327,19 @@ void MyFrame::OnNotebookPageClose(wxAuiNotebookEvent& evt)
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnNotebookPageClosed(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
wxAuiNotebook* ctrl = (wxAuiNotebook*)evt.GetEventObject();
|
||||
|
||||
// selection should always be a valid index
|
||||
wxASSERT_MSG( ctrl->GetSelection() < (int)ctrl->GetPageCount(),
|
||||
wxString::Format("Invalid selection %d, only %d pages left",
|
||||
ctrl->GetSelection(),
|
||||
(int)ctrl->GetPageCount()) );
|
||||
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void MyFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
// for the purpose of this test application, explicitly
|
||||
|
Reference in New Issue
Block a user