[gnome-music/wip/mschraal/texturecache-memory-size-improvements: 2/9] coverpaintable: Improve invalidation logic




commit 342d620f0352ed4e691fe83f36f3d1ec73de3965
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Apr 17 11:39:54 2022 +0200

    coverpaintable: Improve invalidation logic
    
    This improves the case in which the texture goes from being filled back
    to None.

 gnomemusic/coverpaintable.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index deb2e68e6..d4ac2a539 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -184,9 +184,11 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
 
     def _on_texture_cache(
             self, texture_cache: TextureCache, texture: Gdk.Texture) -> None:
-        if texture:
-            self._texture = texture
-            self.invalidate_contents()
+        if texture == self._texture:
+            return
+
+        self._texture = texture
+        self.invalidate_contents()
 
     @GObject.Property(type=object, flags=GObject.ParamFlags.READWRITE)
     def icon_type(self) -> DefaultIconType:


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