From 9ea8feec37dc18c6373ec2fefee1f9e720bc8b82 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Nov 2021 01:18:55 +0000 Subject: [PATCH] Make GetUpdatedImageListFor() work when using old API too Return the image list set via {Set,Assign}ImageList() if SetImages() hadn't been called to make this function return the correct image list in any case, both when using the old wxImageList API and the new one using wxBitmapBundle. This commit is best viewed ignoring whitespace-only changes. --- include/wx/withimages.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/wx/withimages.h b/include/wx/withimages.h index d8a60ac94a..697c842f43 100644 --- a/include/wx/withimages.h +++ b/include/wx/withimages.h @@ -108,16 +108,16 @@ public: // the appropriate size for the given window, and returns it. wxImageList* GetUpdatedImageListFor(wxWindow* win) { - if ( m_images.empty() ) - return NULL; + if ( !m_images.empty() ) + { + // Note that we can't just call AssignImageList() here to avoid + // infinite recursion. + FreeIfNeeded(); + m_imageList = wxBitmapBundle::CreateImageList(win, m_images); - // Note that we can't just call AssignImageList() here to avoid - // infinite recursion. - FreeIfNeeded(); - m_imageList = wxBitmapBundle::CreateImageList(win, m_images); - - // We always own it as we created it ourselves. - m_ownsImageList = true; + // We always own it as we created it ourselves. + m_ownsImageList = true; + } return m_imageList; }