From 1298441f18e6f3cc8538a4a37c0dcdc9b3f3f349 Mon Sep 17 00:00:00 2001 From: Qua-non Date: Thu, 13 Sep 2012 03:32:21 +0530 Subject: [PATCH] UrlRequest: ensure on_success is called for small chunks too --- kivy/network/urlrequest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kivy/network/urlrequest.py b/kivy/network/urlrequest.py index 9e144cfed..0d521427e 100644 --- a/kivy/network/urlrequest.py +++ b/kivy/network/urlrequest.py @@ -155,7 +155,8 @@ class UrlRequest(Thread): else: q(('success', resp, result)) - self._trigger_result() + # using trigger can result in a missed on_success event + self._dispatch_result(0) def _fetch_url(self, url, body, headers, q): # Parse and fetch the current url @@ -219,6 +220,10 @@ class UrlRequest(Thread): # report progress to user q(('progress', resp, (bytes_so_far, total_size))) trigger() + # ensure that restults are dispatch for the last chunk, + # avaoid trigger + self._dispatch_result(0) + q(('progress', resp, (bytes_so_far, total_size))) else: result = resp.read() req.close()