Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/opds.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@sugarlabs.org>2011-04-14 17:22:02 (GMT)
committer Gonzalo Odiard <godiard@sugarlabs.org>2011-04-14 17:22:02 (GMT)
commit4fdab96973d992c14e27e14cec570db72bbc305e (patch)
tree815ff363ab32fcf608aaba2897ff7e1198accb98 /opds.py
parentf3d250c253c9ff9cf3f845bdaf72b41a790093aa (diff)
Use gobject.idle_add to emit signals
This is to avoid crash because we try to update the ui at a wrong time
Diffstat (limited to 'opds.py')
-rw-r--r--opds.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/opds.py b/opds.py
index a97ffbb..c40f896 100644
--- a/opds.py
+++ b/opds.py
@@ -424,7 +424,7 @@ class DownloadIAThread(threading.Thread):
self.obj._booklist.append(IABook(None, entry, ''))
os.remove(tempfile)
- self.obj.emit('updated', self.midway)
+ gobject.idle_add(self.obj.notify_updated, self.midway)
self.obj._ready = True
return False
@@ -451,6 +451,9 @@ class InternetArchiveQueryResult(QueryResult):
self.threads = []
self._start_download()
+ def notify_updated(self, midway):
+ self.emit('updated', midway)
+
def _start_download(self, midway=False):
d_thread = DownloadIAThread(self, midway)
self.threads.append(d_thread)
@@ -478,7 +481,7 @@ class ImageDownloaderThread(threading.Thread):
self._getter.start(path)
except:
_logger.debug("Connection timed out for")
- self.obj.emit('updated', None)
+ gobject.idle_add(self.obj.notify_updated, None)
self._download_content_length = \
self._getter.get_content_length()
@@ -487,7 +490,7 @@ class ImageDownloaderThread(threading.Thread):
def _get_image_result_cb(self, getter, tempfile, suggested_name):
_logger.debug("Got Cover Image %s (%s)", tempfile, suggested_name)
self._getter = None
- self.obj.emit('updated', tempfile)
+ gobject.idle_add(self.obj.notify_updated, tempfile)
def _get_image_progress_cb(self, getter, bytes_downloaded):
if self._download_content_length > 0:
@@ -504,7 +507,7 @@ class ImageDownloaderThread(threading.Thread):
self._download_content_length = 0
self._download_content_type = None
self._getter = None
- self.obj.emit('updated', None)
+ gobject.idle_add(self.obj.notify_updated, None)
def run(self):
self._download_image()
@@ -532,3 +535,6 @@ class ImageDownloader(gobject.GObject):
d_thread = ImageDownloaderThread(self)
self.threads.append(d_thread)
d_thread.start()
+
+ def notify_updated(self, temp_file):
+ self.emit('updated', temp_file)