[Xfce4-commits] <xfce4-cpugraph-plugin:master> Fix cpu reading when only reading the total usage

Florian noreply at xfce.org
Sat Apr 17 16:16:37 CEST 2010


Updating branch refs/heads/master
         to e1d75ed7673c6624e24f41b954fbb28bdf4e8af8 (commit)
       from 40d3a89b75febda48e91af6c8c4a4ef1ba8a10e0 (commit)

commit e1d75ed7673c6624e24f41b954fbb28bdf4e8af8
Author: Florian <frivoal at gmail.com>
Date:   Thu Mar 11 10:13:30 2010 +0900

    Fix cpu reading when only reading the total usage
    
    On systems like *BSDs where we currently only track the total cpu usage,
    regardless of the number of cores, the code that updates the bars was
    wrong, trying to read from a non existing data source for the first
    core, instead of the one for total cpu usage.

 panel-plugin/cpu.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index f493754..cfbe4df 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -172,9 +172,18 @@ static gboolean update_cb( CPUGraph * base )
 	gint i;
 	if( !read_cpu_data( base->cpu_data, base->nr_cores ) )
 		return TRUE;
-	for( i=0; i<base->nr_cores; i++ )
+	if( base->nr_cores == 1 )
+	{
+		gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(base->m_pBar[0]),
+		                               (gdouble)base->cpu_data[0].load / CPU_SCALE
+		                             );
+	}
+	else
 	{
-		gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(base->m_pBar[i]), (gdouble)base->cpu_data[i+1].load / CPU_SCALE );
+		for( i=0; i<base->nr_cores; i++ )
+			gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(base->m_pBar[i]),
+			                               (gdouble)base->cpu_data[i+1].load / CPU_SCALE
+			                             );
 	}
 
 	if( base->non_linear )



More information about the Xfce4-commits mailing list