From d2c77146dbe75727c1384dfc88e82ce20d0fb2e1 Mon Sep 17 00:00:00 2001 From: F Date: Sat, 1 Sep 2018 11:33:03 +0200 Subject: [PATCH] wxImageList::GetIcon() converts wxBitmap to wxIcon instead of wxNullIcon on OSX (#906) On OSX, wxImageList::GetIcon() returned wxNullIcon when a wxBitmap was stored. This could lead to no image seen in controls like wxTreeListCtrl. Instead of that, we convert the wxBitmap to wxIcon with CopyFromBitmap. --- src/osx/imaglist.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/osx/imaglist.cpp b/src/osx/imaglist.cpp index b057fe3c3f..32f12fb4ee 100644 --- a/src/osx/imaglist.cpp +++ b/src/osx/imaglist.cpp @@ -147,13 +147,13 @@ wxIcon wxImageList::GetIcon(int index) const wxObject* obj = (wxObject*) node->GetData(); if ( obj == NULL ) return wxNullIcon ; - else if ( obj->IsKindOf(CLASSINFO(wxBitmap)) ) + if ( obj->IsKindOf(CLASSINFO(wxBitmap)) ) { - wxFAIL_MSG( wxT("cannot convert from bitmap to icon") ) ; - return wxNullIcon ; + wxIcon icon; + icon.CopyFromBitmap(*static_cast(obj)); + return icon; } - else - return *(static_cast(obj)) ; + return *(static_cast(obj)) ; } bool wxImageList::Replace( int index, const wxBitmap &bitmap )