From af6a61e3a03f2f4f71a0a227ab2f984deb5be699 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Mar 2018 00:07:00 +0100 Subject: [PATCH] Update wxBookCtrlBase::m_selection outside UpdateSelectedPage() Change m_selection in wxBookCtrlBase::DoSetSelection() itself instead of requiring all the derived class overriding do it in their overridden UpdateSelectedPage(). No real changes, this is just a small simplification. --- include/wx/choicebk.h | 3 +-- include/wx/simplebook.h | 5 +++-- src/common/bookctrl.cpp | 1 + src/generic/listbkg.cpp | 1 - src/generic/toolbkg.cpp | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/wx/choicebk.h b/include/wx/choicebk.h index f32e8d3a0d..aca809932d 100644 --- a/include/wx/choicebk.h +++ b/include/wx/choicebk.h @@ -86,8 +86,7 @@ protected: void UpdateSelectedPage(size_t newsel) wxOVERRIDE { - m_selection = static_cast(newsel); - GetChoiceCtrl()->Select(m_selection); + GetChoiceCtrl()->Select(newsel); } wxBookCtrlEvent* CreatePageChangingEvent() const wxOVERRIDE; diff --git a/include/wx/simplebook.h b/include/wx/simplebook.h index 7e819700fc..fa859d3044 100644 --- a/include/wx/simplebook.h +++ b/include/wx/simplebook.h @@ -155,9 +155,10 @@ public: } protected: - virtual void UpdateSelectedPage(size_t newsel) wxOVERRIDE + virtual void UpdateSelectedPage(size_t WXUNUSED(newsel)) wxOVERRIDE { - m_selection = (int)newsel; + // Nothing to do here, but must be overridden to avoid the assert in + // the base class version. } virtual wxBookCtrlEvent* CreatePageChangingEvent() const wxOVERRIDE diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 969ae07a70..e027fd9052 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -500,6 +500,7 @@ int wxBookCtrlBase::DoSetSelection(size_t n, int flags) DoShowPage(page, true); // change selection now to ignore the selection change event + m_selection = n; UpdateSelectedPage(n); if ( flags & SetSelection_SendEvent ) diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index a7f9229d5e..93084375a1 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -293,7 +293,6 @@ void wxListbook::SetImageList(wxImageList *imageList) void wxListbook::UpdateSelectedPage(size_t newsel) { - m_selection = newsel; GetListView()->Select(newsel); GetListView()->Focus(newsel); } diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index 40ea3a99c2..07cd9fa962 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -197,7 +197,6 @@ void wxToolbook::MakeChangedEvent(wxBookCtrlEvent &event) void wxToolbook::UpdateSelectedPage(size_t newsel) { - m_selection = newsel; GetToolBar()->ToggleTool(newsel + 1, true); }