Skip to contentSkip to conversation

xfce4-cpufreq-plugin: Fix memory leak and reduce CPU load

PATCH New Andreas Müller 1 participant 3 messages May 6, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 xfce4-cpufreq-plugin: Fix memory leak and reduce CPU load

---
 ...ry-leak-and-reduce-cpu-load-slightly.patch | 121 ++++++++++++++++++
 .../cpufreq/xfce4-cpufreq-plugin_1.2.1.bb     |   1 +
 2 files changed, 122 insertions(+)
 create mode 100644 meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin/0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch
meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin/0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch new file +121 -0
new file mode 100644
index 000000000..92a6e8384
@@ -0,0 +1,121 @@
+From f86486e128f62ed5a531163535d11f0aa0268928 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20M=C3=BCller?= <[email protected]>
+Date: Sun, 5 May 2019 20:45:26 +0200
+Subject: [PATCH] Fix memory-leak and reduce cpu-load slightly
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* when setting font remove old css provider befor setting new
+  -> fix memory leak
+* do call cpufreq_label_set_font only on init and when font was changed
+  -> reduce cpu-load
+
+Fixes https://bugzilla.xfce.org/show_bug.cgi?id=15218
+
+Upstream-Status: Submitted [1]
+
+[1] https://bugzilla.xfce.org/attachment.cgi?id=8492
+
+Signed-off-by: Andreas Müller <[email protected]>
+---
+ panel-plugin/xfce4-cpufreq-configure.c |  4 ++++
+ panel-plugin/xfce4-cpufreq-plugin.c    | 13 +++++++++++--
+ panel-plugin/xfce4-cpufreq-plugin.h    |  2 ++
+ 3 files changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c
+index 1205fc9..48e72ff 100644
+--- a/panel-plugin/xfce4-cpufreq-configure.c
++++ b/panel-plugin/xfce4-cpufreq-configure.c
+@@ -85,7 +85,10 @@ button_fontname_update(GtkWidget *button, gboolean update_plugin)
+   }
+ 
+   if (update_plugin)
++  {
++    cpufreq_label_set_font ();
+     cpufreq_update_plugin (TRUE);
++  }
+ }
+ 
+ 
+@@ -155,6 +158,7 @@ button_fontcolor_clicked (GtkWidget *button, void *data)
+   gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), color);
+   cpuFreq->options->fontcolor = gdk_rgba_to_string (color);
+   g_free (color);
++  cpufreq_label_set_font ();
+   cpufreq_update_plugin (TRUE);
+ }
+ 
+diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
+index e886121..8d7c9e5 100644
+--- a/panel-plugin/xfce4-cpufreq-plugin.c
++++ b/panel-plugin/xfce4-cpufreq-plugin.c
+@@ -44,6 +44,7 @@ cpufreq_label_set_font (void)
+ {
+   gchar *css = NULL, *css_font = NULL, *css_color = NULL;
+   GtkCssProvider *provider;
++  GtkStyleContext *context;
+   PangoFontDescription *font;
+ 
+   if (G_UNLIKELY (cpuFreq->label == NULL))
+@@ -76,11 +77,17 @@ cpufreq_label_set_font (void)
+   if (css)
+   {
+     provider = gtk_css_provider_new ();
++    context = GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label)));
++
++    if (currentProvider)
++      gtk_style_context_remove_provider (context, currentProvider);
+ 
+     gtk_css_provider_load_from_data (provider, css, -1, NULL);
+     gtk_style_context_add_provider (
+-      GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))),
++      context,
+       GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
++
++    currentProvider = provider;
+   }
+ 
+   g_free (css);
+@@ -420,7 +427,6 @@ cpufreq_update_plugin (gboolean reset_label_size)
+ 
+   if (cpuFreq->layout_changed)
+   {
+-    cpufreq_label_set_font ();
+     cpufreq_widgets_layout ();
+   }
+ 
+@@ -601,6 +607,7 @@ cpufreq_widgets (void)
+ 
+   gtk_widget_show_all (cpuFreq->button);
+ 
++  cpufreq_label_set_font ();
+   cpufreq_update_plugin (TRUE);
+ }
+ 
+@@ -775,6 +782,8 @@ cpufreq_construct (XfcePanelPlugin *plugin)
+ {
+   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+ 
++  currentProvider = NULL;
++
+   cpuFreq = g_new0 (CpuFreqPlugin, 1);
+   cpuFreq->options = g_new0 (CpuFreqPluginOptions, 1);
+   cpuFreq->plugin = plugin;
+diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h
+index a6895e4..6338698 100644
+--- a/panel-plugin/xfce4-cpufreq-plugin.h
++++ b/panel-plugin/xfce4-cpufreq-plugin.h
+@@ -95,6 +95,8 @@ typedef struct
+ 
+ CpuFreqPlugin *cpuFreq;
+ 
++GtkCssProvider *currentProvider;
++
+ G_BEGIN_DECLS
+ 
+ void
+-- 
+2.20.1
+
meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin_1.2.1.bb +1 -0
index 3f5587d80..6addc3b65 100644
@@ -7,3 +7,4 @@ inherit xfce-panel-plugin
 
 SRC_URI[md5sum] = "ccd8f0f7aef51bc4caf1049986d9614f"
 SRC_URI[sha256sum] = "c5e044c0dc401d2066f208a3df82a588b3e51ff01425f155d0a1d0f8fce8f5b5"
+SRC_URI += "file://0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch"
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 packagegroup-meta-networking: replace DISTRO_FEATURE by DISTRO_FEATURES

---
 .../packagegroups/packagegroup-meta-networking.bb   | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta-networking/recipes-core/packagegroups/packagegroup-meta-networking.bb +7 -6
index 63ad34cb8..64eabe462 100644
@@ -38,8 +38,9 @@ RDEPENDS_packagegroup-meta-networking-connectivity = "\
     inetutils wolfssl lftp miniupnpd networkmanager \
     networkmanager-openvpn rdist nanomsg python-networkmanager \
     wireless-regdb \
-    ${@bb.utils.contains("DISTRO_FEATURE", "bluez5 x11", "blueman", "", d)} \
-    ${@bb.utils.contains("DISTRO_FEATURE", "pam", "samba", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "bluez5 x11", "blueman", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "pam", "samba", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "pam", "samba", "", d)} \
     "
 
 RDEPENDS_packagegroup-meta-networking-daemons = "\
@@ -47,7 +48,7 @@ RDEPENDS_packagegroup-meta-networking-daemons = "\
     ptpd igmpproxy opensaf squid \
     atftp postfix iscsi-initiator-utils vsftpd cyrus-sasl \
     pure-ftpd vblade tftp-hpa ncftp \
-    ${@bb.utils.contains("DISTRO_FEATURE", "systemd", "networkd-dispatcher", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "networkd-dispatcher", "", d)} \
     "
 
 RDEPENDS_packagegroup-meta-networking-devtools = "\
@@ -56,7 +57,7 @@ RDEPENDS_packagegroup-meta-networking-devtools = "\
 
 RDEPENDS_packagegroup-meta-networking-extended = "\
     corosync \
-    ${@bb.utils.contains("DISTRO_FEATURE", "systemd", "dlm", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "dlm", "", d)} \
     "
 
 RDEPENDS_packagegroup-meta-networking-filter = "\
@@ -85,7 +86,7 @@ RDEPENDS_packagegroup-meta-networking-protocols = "\
     tsocks freediameter xl2tpd babeld mdns net-snmp \
     quagga pptp-linux zeroconf nopoll openflow rp-pppoe \
     radiusclient-ng openl2tp usrsctp \
-    ${@bb.utils.contains("DISTRO_FEATURE", "pam", "dante", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "pam", "dante", "", d)} \
     "
 
 RDEPENDS_packagegroup-meta-networking-support = "\
@@ -104,7 +105,7 @@ RDEPENDS_packagegroup-meta-networking-support = "\
     netcat-openbsd fetchmail yp-tools ypbind-mt yp-tools \
     arptables macchanger nghttp2 strongswan fping \
     dnssec-conf libesmtp cifs-utils open-isns \
-    ${@bb.utils.contains("DISTRO_FEATURE", "pam", "libldb", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "pam", "libldb", "", d)} \
     ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "non-commercial", "netperf", "", d)} \
     ${@bb.utils.contains_any("TRANSLATED_TARGET_ARCH", "i586 x86-64", "spice", "", d)} \
     "
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/3 meta-xfce: add meta-networking to layer depends

In reply to Andreas Müller

* blueman was moved to meta-networking (without an explanation why). It is added to packagegroup-xfce-extended in case 'bluetooth' is in DISTRO_FEATURES
* thunar-shares-plugin RDEPENDS on samba-server

---
 meta-xfce/conf/layer.conf | 1 +
 1 file changed, 1 insertion(+)
meta-xfce/conf/layer.conf +1 -0
index 6e9d89294..fd7f9b541 100644
@@ -17,6 +17,7 @@ LAYERDEPENDS_xfce-layer += "openembedded-layer"
 LAYERDEPENDS_xfce-layer += "gnome-layer"
 LAYERDEPENDS_xfce-layer += "multimedia-layer"
 LAYERDEPENDS_xfce-layer += "meta-python"
+LAYERDEPENDS_xfce-layer += "networking-layer"
 
 LAYERSERIES_COMPAT_xfce-layer = "thud warrior"
 
Signature · 1 line
2.20.1