[gnome-music/wip/mschraal/texturecache-memory-size-improvements: 1/9] texturecache: Add function to clear the texture callback
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/texturecache-memory-size-improvements: 1/9] texturecache: Add function to clear the texture callback
- Date: Wed, 20 Apr 2022 21:34:29 +0000 (UTC)
commit 7896a3c7ceba26fc8bbb568468a4b1fe6050e0ea
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Apr 18 15:13:56 2022 +0200
texturecache: Add function to clear the texture callback
In CoverPaintable the texture callback could stil be called when the
object was already changed, resulting in some rare cases in which the
wrong art was shown.
Add a call to clear the callback as a makeshift solution.
Related: #500
gnomemusic/coverpaintable.py | 2 ++
gnomemusic/texturecache.py | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index 5b825dea6..deb2e68e6 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -150,6 +150,8 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
if coreobject is self._coreobject:
return
+ self._texture_cache.clear_pending_lookup_callback()
+
self._texture = None
self.invalidate_contents()
diff --git a/gnomemusic/texturecache.py b/gnomemusic/texturecache.py
index 271afb7ef..2d1edadfd 100644
--- a/gnomemusic/texturecache.py
+++ b/gnomemusic/texturecache.py
@@ -62,6 +62,13 @@ class TextureCache(GObject.GObject):
self._art_loading_id = 0
self._uri = ""
+ def clear_pending_lookup_callback(self) -> None:
+ """Disconnect ongoing lookup callback
+ """
+ if self._art_loading_id != 0:
+ self._art_loader.disconnect(self._art_loading_id)
+ self._art_loading_id = 0
+
def lookup(self, uri: str) -> None:
"""Look up a texture for the given MediaArt uri
@@ -69,9 +76,7 @@ class TextureCache(GObject.GObject):
"""
self._uri = uri
- if self._art_loading_id != 0:
- self._art_loader.disconnect(self._art_loading_id)
- self._art_loading_id = 0
+ self.clear_pending_lookup_callback()
if uri in self._textures.keys():
self.emit("texture", self._textures[uri])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]