From ca1eefdba21f1ad83e2ad2089272f1afd479ade5 Mon Sep 17 00:00:00 2001 From: Alexander Koshelev Date: Tue, 22 Feb 2022 17:17:22 +0100 Subject: [PATCH] Fix usage of wxWithImages::Images in wxTreebook --- include/wx/treebook.h | 4 ++-- src/generic/treebkg.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/wx/treebook.h b/include/wx/treebook.h index 7bd8451259..11b44cfc65 100644 --- a/include/wx/treebook.h +++ b/include/wx/treebook.h @@ -132,14 +132,14 @@ public: virtual int SetSelection(size_t n) wxOVERRIDE { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) wxOVERRIDE { return DoSetSelection(n); } virtual int HitTest(const wxPoint& pt, long *flags = NULL) const wxOVERRIDE; - virtual void SetImageList(wxImageList *imageList) wxOVERRIDE; - virtual void AssignImageList(wxImageList *imageList); virtual bool DeleteAllPages() wxOVERRIDE; protected: // Implementation of a page removal. See DeletPage for comments. wxTreebookPage *DoRemovePage(size_t pos) wxOVERRIDE; + virtual void OnImagesChanged() wxOVERRIDE; + // This subclass of wxBookCtrlBase accepts NULL page pointers (empty pages) virtual bool AllowNullPage() const wxOVERRIDE { return true; } virtual wxWindow *TryGetNonNullPage(size_t page) wxOVERRIDE; diff --git a/src/generic/treebkg.cpp b/src/generic/treebkg.cpp index b408f8cb0a..876341e455 100644 --- a/src/generic/treebkg.cpp +++ b/src/generic/treebkg.cpp @@ -564,16 +564,15 @@ wxWindow *wxTreebook::TryGetNonNullPage(size_t n) return page; } -void wxTreebook::SetImageList(wxImageList *imageList) +void wxTreebook::OnImagesChanged() { - wxBookCtrlBase::SetImageList(imageList); - GetTreeCtrl()->SetImageList(imageList); -} - -void wxTreebook::AssignImageList(wxImageList *imageList) -{ - wxBookCtrlBase::AssignImageList(imageList); - GetTreeCtrl()->SetImageList(imageList); + // Propagate the images to the tree control which will actually use them. + wxTreeCtrl* const tree = GetTreeCtrl(); + const Images& images = GetImages(); + if ( !images.empty() ) + tree->SetImages(images); + else + tree->SetImageList(GetImageList()); } // ----------------------------------------------------------------------------