[gnome-music/wip/mschraal/texturecache-memory-size-improvements: 7/9] texturecache: Drop instance wide use of uri variable




commit 44757dc58f3f9d76d60b760cf45b9cfa70962a4c
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Apr 12 17:00:37 2022 +0200

    texturecache: Drop instance wide use of uri variable

 gnomemusic/texturecache.py | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/texturecache.py b/gnomemusic/texturecache.py
index e4b1a22c6..e9f177a17 100644
--- a/gnomemusic/texturecache.py
+++ b/gnomemusic/texturecache.py
@@ -74,7 +74,6 @@ class TextureCache(GObject.GObject):
 
         self._art_loader: MediaArtLoader
         self._art_loading_id = 0
-        self._uri = ""
 
     def clear_pending_lookup_callback(self) -> None:
         """Disconnect ongoing lookup callback
@@ -88,8 +87,6 @@ class TextureCache(GObject.GObject):
 
         :param str uri: The MediaArt uri
         """
-        self._uri = uri
-
         self.clear_pending_lookup_callback()
 
         if uri in TextureCache._textures.keys():
@@ -98,22 +95,22 @@ class TextureCache(GObject.GObject):
                     TextureCache.LoadingState.AVAILABLE,
                     TextureCache.LoadingState.UNAVAILABLE]:
                 self.emit("texture", texture)
-                TextureCache._textures[self._uri] = (
-                    state, time.time(), texture)
+                TextureCache._textures[uri] = (state, time.time(), texture)
                 return
 
         self._art_loader = MediaArtLoader()
         self._art_loading_id = self._art_loader.connect(
-            "finished", self._on_art_loading_finished)
-        self._async_queue.queue(self._art_loader, self._uri)
+            "finished", self._on_art_loading_finished, uri)
+        self._async_queue.queue(self._art_loader, uri)
 
     def _on_art_loading_finished(
-            self, art_loader: MediaArtLoader, texture: Gdk.Texture) -> None:
+            self, art_loader: MediaArtLoader, texture: Gdk.Texture,
+            uri: str) -> None:
         if texture:
             state = TextureCache.LoadingState.AVAILABLE
         else:
             state = TextureCache.LoadingState.UNAVAILABLE
 
-        TextureCache._textures[self._uri] = (state, time.time(), texture)
+        TextureCache._textures[uri] = (state, time.time(), texture)
 
         self.emit("texture", texture)


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