[gnome-music/wip/mschraal/file-exists-async: 7/8] artcache/storeart: Emit signal emission after I/O finish




commit 7710d1a5fa8ae279ffec945b867cda90d680ac79
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Aug 15 22:58:04 2021 +0200

    artcache/storeart: Emit signal emission after I/O finish
    
    The point of the AsyncQueue is to not do too much I/O simultanously.
    That involves all steps, including closing streams properly.

 gnomemusic/artcache.py | 5 ++++-
 gnomemusic/storeart.py | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 138580c8c..cd5138781 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -55,6 +55,7 @@ class ArtCache(GObject.GObject):
 
         self._coreobject = None
         self._default_icon = None
+        self._surface = None
 
     def start(self, coreobject, size, scale):
         """Start the cache query
@@ -121,7 +122,7 @@ class ArtCache(GObject.GObject):
                 or isinstance(self._coreobject, CoreSong)):
             surface = make_icon_frame(surface, self._size, self._scale)
 
-        self.emit("finished", surface)
+        self._surface = surface
 
     def _close_stream(self, stream, result, data):
         try:
@@ -129,3 +130,5 @@ class ArtCache(GObject.GObject):
         except GLib.Error as error:
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
+
+        self.emit("finished", self._surface)
diff --git a/gnomemusic/storeart.py b/gnomemusic/storeart.py
index 89f13c0ec..a1ff57664 100644
--- a/gnomemusic/storeart.py
+++ b/gnomemusic/storeart.py
@@ -166,8 +166,6 @@ class StoreArt(GObject.Object):
         self._coreobject.props.media.set_thumbnail(cache_file.get_uri())
         self._coreobject.props.thumbnail = cache_file.get_uri()
 
-        self.emit("finished")
-
         tmp_file.delete_async(
             GLib.PRIORITY_LOW, None, self._delete_callback, None)
 
@@ -177,3 +175,5 @@ class StoreArt(GObject.Object):
         except GLib.Error as error:
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
+
+        self.emit("finished")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]