Prevent redrawing cover image if size has not changed

Drawing the cover image on the Cover panel triggers the re-allocation of
the widget which in turn triggers the re-drawing of the cover image.
This led to an infinite loop of drawing the cover image causing high CPU
usage. To prevent this, the widget size is now stored and the the
resizing of the cover image is only done if the size has really changed.
This commit is contained in:
coderkun 2018-11-10 16:29:46 +01:00
parent bb4bf89079
commit 34153044b4

View file

@ -810,6 +810,7 @@ class CoverPanel(GObject.GObject):
self._tracklist_size = TracklistSize.LARGE
self._icon_theme = Gtk.IconTheme.get_default()
self._fullscreened = False
self._current_size = None
# Widgets
self._appwindow = builder.get_object('appwindow')
@ -1066,8 +1067,15 @@ class CoverPanel(GObject.GObject):
"""Diese Methode skaliert das geladene Bild aus dem Pixelpuffer
auf die Größe des Fensters unter Beibehalt der Seitenverhältnisse
"""
pixbuf = self._cover_pixbuf
# Get size
size = self._cover_scroll.get_allocation()
# Abort if size is the same
if self._current_size and size.width == self._current_size.width and size.height == self._current_size.height:
return
self._current_size = size
# Get pixelbuffer
pixbuf = self._cover_pixbuf
# Check pixelbuffer
if pixbuf is None:
return