From 34153044b40f235e13abbbb185c2b8ac10f0eb24 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 10 Nov 2018 16:29:46 +0100 Subject: [PATCH 1/2] 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 From 424f9f200b0def0521fff1faedc39d6349d5b074 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 10 Nov 2018 16:34:06 +0100 Subject: [PATCH 2/2] Bump version to 1.3.5 --- data/gtk.glade | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/gtk.glade b/data/gtk.glade index 9147c98..4ca5d91 100644 --- a/data/gtk.glade +++ b/data/gtk.glade @@ -1434,7 +1434,7 @@ center appwindow CoverGrid - 1.3.4 + 1.3.5 CoverGrid is a client for the Music Player Daemon, focusing on albums instead of single tracks. http://www.suruatoel.xyz/codes/mcg mcg.svg diff --git a/setup.py b/setup.py index 5c92b2e..58eccaf 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ setup( 'build_py': build_mcg }, name = "mcg", - version = '1.3.4', + version = '1.3.5', description = "CoverGrid (mcg) is a client for the Music Player Daemon, focusing on albums instead of single tracks.", url = "http://www.suruatoel.xyz/codes/mcg", author = "coderkun",