diff options
author | Andreas Müller <schnitzeltony@gmail.com> | 2019-05-06 10:15:43 +0200 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2019-05-06 08:32:04 -0700 |
commit | 97974627609958b6cc2b9ea19026bcf2a34a671f (patch) | |
tree | 6d0ea4d22f7636011eab44cc3c7c086172e5309e /meta-xfce/recipes-panel-plugins/cpufreq | |
parent | 5a6e952b79aac64afd79d787a671a262cf1e90eb (diff) | |
download | meta-openembedded-97974627609958b6cc2b9ea19026bcf2a34a671f.tar.gz |
xfce4-cpufreq-plugin: Fix memory leak and reduce CPU load
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-xfce/recipes-panel-plugins/cpufreq')
2 files changed, 122 insertions, 0 deletions
diff --git a/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin/0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch b/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin/0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch new file mode 100644 index 000000000..92a6e8384 --- /dev/null +++ b/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin/0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch | |||
@@ -0,0 +1,121 @@ | |||
1 | From f86486e128f62ed5a531163535d11f0aa0268928 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com> | ||
3 | Date: Sun, 5 May 2019 20:45:26 +0200 | ||
4 | Subject: [PATCH] Fix memory-leak and reduce cpu-load slightly | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | * when setting font remove old css provider befor setting new | ||
10 | -> fix memory leak | ||
11 | * do call cpufreq_label_set_font only on init and when font was changed | ||
12 | -> reduce cpu-load | ||
13 | |||
14 | Fixes https://bugzilla.xfce.org/show_bug.cgi?id=15218 | ||
15 | |||
16 | Upstream-Status: Submitted [1] | ||
17 | |||
18 | [1] https://bugzilla.xfce.org/attachment.cgi?id=8492 | ||
19 | |||
20 | Signed-off-by: Andreas Müller <schnitzeltony@gmail.com> | ||
21 | --- | ||
22 | panel-plugin/xfce4-cpufreq-configure.c | 4 ++++ | ||
23 | panel-plugin/xfce4-cpufreq-plugin.c | 13 +++++++++++-- | ||
24 | panel-plugin/xfce4-cpufreq-plugin.h | 2 ++ | ||
25 | 3 files changed, 17 insertions(+), 2 deletions(-) | ||
26 | |||
27 | diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c | ||
28 | index 1205fc9..48e72ff 100644 | ||
29 | --- a/panel-plugin/xfce4-cpufreq-configure.c | ||
30 | +++ b/panel-plugin/xfce4-cpufreq-configure.c | ||
31 | @@ -85,7 +85,10 @@ button_fontname_update(GtkWidget *button, gboolean update_plugin) | ||
32 | } | ||
33 | |||
34 | if (update_plugin) | ||
35 | + { | ||
36 | + cpufreq_label_set_font (); | ||
37 | cpufreq_update_plugin (TRUE); | ||
38 | + } | ||
39 | } | ||
40 | |||
41 | |||
42 | @@ -155,6 +158,7 @@ button_fontcolor_clicked (GtkWidget *button, void *data) | ||
43 | gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), color); | ||
44 | cpuFreq->options->fontcolor = gdk_rgba_to_string (color); | ||
45 | g_free (color); | ||
46 | + cpufreq_label_set_font (); | ||
47 | cpufreq_update_plugin (TRUE); | ||
48 | } | ||
49 | |||
50 | diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c | ||
51 | index e886121..8d7c9e5 100644 | ||
52 | --- a/panel-plugin/xfce4-cpufreq-plugin.c | ||
53 | +++ b/panel-plugin/xfce4-cpufreq-plugin.c | ||
54 | @@ -44,6 +44,7 @@ cpufreq_label_set_font (void) | ||
55 | { | ||
56 | gchar *css = NULL, *css_font = NULL, *css_color = NULL; | ||
57 | GtkCssProvider *provider; | ||
58 | + GtkStyleContext *context; | ||
59 | PangoFontDescription *font; | ||
60 | |||
61 | if (G_UNLIKELY (cpuFreq->label == NULL)) | ||
62 | @@ -76,11 +77,17 @@ cpufreq_label_set_font (void) | ||
63 | if (css) | ||
64 | { | ||
65 | provider = gtk_css_provider_new (); | ||
66 | + context = GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))); | ||
67 | + | ||
68 | + if (currentProvider) | ||
69 | + gtk_style_context_remove_provider (context, currentProvider); | ||
70 | |||
71 | gtk_css_provider_load_from_data (provider, css, -1, NULL); | ||
72 | gtk_style_context_add_provider ( | ||
73 | - GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))), | ||
74 | + context, | ||
75 | GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); | ||
76 | + | ||
77 | + currentProvider = provider; | ||
78 | } | ||
79 | |||
80 | g_free (css); | ||
81 | @@ -420,7 +427,6 @@ cpufreq_update_plugin (gboolean reset_label_size) | ||
82 | |||
83 | if (cpuFreq->layout_changed) | ||
84 | { | ||
85 | - cpufreq_label_set_font (); | ||
86 | cpufreq_widgets_layout (); | ||
87 | } | ||
88 | |||
89 | @@ -601,6 +607,7 @@ cpufreq_widgets (void) | ||
90 | |||
91 | gtk_widget_show_all (cpuFreq->button); | ||
92 | |||
93 | + cpufreq_label_set_font (); | ||
94 | cpufreq_update_plugin (TRUE); | ||
95 | } | ||
96 | |||
97 | @@ -775,6 +782,8 @@ cpufreq_construct (XfcePanelPlugin *plugin) | ||
98 | { | ||
99 | xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); | ||
100 | |||
101 | + currentProvider = NULL; | ||
102 | + | ||
103 | cpuFreq = g_new0 (CpuFreqPlugin, 1); | ||
104 | cpuFreq->options = g_new0 (CpuFreqPluginOptions, 1); | ||
105 | cpuFreq->plugin = plugin; | ||
106 | diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h | ||
107 | index a6895e4..6338698 100644 | ||
108 | --- a/panel-plugin/xfce4-cpufreq-plugin.h | ||
109 | +++ b/panel-plugin/xfce4-cpufreq-plugin.h | ||
110 | @@ -95,6 +95,8 @@ typedef struct | ||
111 | |||
112 | CpuFreqPlugin *cpuFreq; | ||
113 | |||
114 | +GtkCssProvider *currentProvider; | ||
115 | + | ||
116 | G_BEGIN_DECLS | ||
117 | |||
118 | void | ||
119 | -- | ||
120 | 2.20.1 | ||
121 | |||
diff --git a/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin_1.2.1.bb b/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin_1.2.1.bb index 3f5587d80..6addc3b65 100644 --- a/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin_1.2.1.bb +++ b/meta-xfce/recipes-panel-plugins/cpufreq/xfce4-cpufreq-plugin_1.2.1.bb | |||
@@ -7,3 +7,4 @@ inherit xfce-panel-plugin | |||
7 | 7 | ||
8 | SRC_URI[md5sum] = "ccd8f0f7aef51bc4caf1049986d9614f" | 8 | SRC_URI[md5sum] = "ccd8f0f7aef51bc4caf1049986d9614f" |
9 | SRC_URI[sha256sum] = "c5e044c0dc401d2066f208a3df82a588b3e51ff01425f155d0a1d0f8fce8f5b5" | 9 | SRC_URI[sha256sum] = "c5e044c0dc401d2066f208a3df82a588b3e51ff01425f155d0a1d0f8fce8f5b5" |
10 | SRC_URI += "file://0001-Fix-memory-leak-and-reduce-cpu-load-slightly.patch" | ||