rs/SDWebImage — pull request #372 by cfis (2013-04-26 22:33:03+00:00)
Title: SDWebImageOperation - Trying to avoid crashes #341 and #364

This is an attempt to avoid the crashes in #341. It won't fix the underlying issue but I hope it will avoid it in most cases. The various crash reports indicate the underlying download operation is being freed before the async block in dataReceived is being executed. This fix change tries to avoid every calling the async block.

In addition I would like to remove all these async blocks on the main queue. Besides not working (we see a ton of crashes in this code - happy to forward them all), I am using SDWebImage to download map tiles on a background thread via the use of a NSURLProtocol. The callbacks should come back on that thread, but the async blocks make the impossible.

Instead, it should be the responsibility of the calling code of the download operation that sets things up on the right thread/queue, not the download operation itself. So if I want to start a download on a background thread, the callbacks should come back on that thread (obviously NRURLConnection will do the actual download on whatever thread it wants).

Happy to put a patch together if that makes sense to you.

Thanks - Charlie