From 34153044b40f235e13abbbb185c2b8ac10f0eb24 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 10 Nov 2018 16:29:46 +0100 Subject: [PATCH] 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. --- mcg/widgets.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mcg/widgets.py b/mcg/widgets.py index 1008242..93453fd 100644 --- a/mcg/widgets.py +++ b/mcg/widgets.py @@ -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