sproutcore/sproutcore — pull request #716 by camstevenson (2012-02-20 21:03:33+00:00)
Title: SC.imageQueue stall fix

Fix for bug where subsequent attempts to load a failed/aborted image
will result in SC.imageQueue queue processing being stalled

Symptom:

- We have a grid view containing grid cells, each containing an SC.ImageView
- One of the referenced images doesn't exist (so results in a 404 error)
- The first time the cell referencing the failed image is displayed, the behavior is as expected (no image is displayed, other images are displayed correctly)
- Scrolling the "failed image cell" out of the view and then back in causes all cells to show empty (no images loaded

Cause:

- In frameworks/foundation/system/image_queue.js, the imageStatusDidChange method sets the status of a failed/aborted image to this.IMAGE_WAITING so that further attempts to load the image will result in a retry
- Along with this, however, imageStatusDidChange also sets the "image" member of the queue entry to null
- The next time there is an attempt to load the (previously failed) queued image, this ends up causing loadNextImage() to simply return because entry.image is null, which causes the queue to stall
(Note that there is a commented out line in loadNextImage which implies that there was a fix applied/attempted previously)

Fix:

- When a queued entry is retrieved in _imageEntryFor, ensure that it has a valid image member