diff --git a/wxPython/wx/lib/customtreectrl.py b/wxPython/wx/lib/customtreectrl.py index 87313192a2..e8dffbe598 100644 --- a/wxPython/wx/lib/customtreectrl.py +++ b/wxPython/wx/lib/customtreectrl.py @@ -3958,21 +3958,22 @@ class CustomTreeCtrl(wx.PyScrolledWindow): self._imageListNormal = imageList self._ownsImageListNormal = False self._dirty = True + # Don't do any drawing if we're setting the list to NULL, # since we may be in the process of deleting the tree control. if imageList: self.CalculateLineHeight() - # We gray out the image list to use the grayed icons with disabled items - self._grayedImageList = wx.ImageList(16, 16, True, 0) - - for ii in xrange(imageList.GetImageCount()): - - bmp = imageList.GetBitmap(ii) - image = wx.ImageFromBitmap(bmp) - image = GrayOut(image) - newbmp = wx.BitmapFromImage(image) - self._grayedImageList.Add(newbmp) + # We gray out the image list to use the grayed icons with disabled items + sz = imageList.GetSize(0) + self._grayedImageList = wx.ImageList(sz[0], sz[1], True, 0) + + for ii in xrange(imageList.GetImageCount()): + bmp = imageList.GetBitmap(ii) + image = wx.ImageFromBitmap(bmp) + image = GrayOut(image) + newbmp = wx.BitmapFromImage(image) + self._grayedImageList.Add(newbmp) def SetStateImageList(self, imageList):