app: avoid potential division by 0 in dashboard CPU usage sampler

This commit is contained in:
Ell 2018-04-04 13:00:40 -04:00
parent fa02a2c64f
commit 394c930fbe
1 changed files with 2 additions and 2 deletions

View File

@ -1644,7 +1644,7 @@ gimp_dashboard_sample_cpu_usage (GimpDashboard *dashboard,
curr_usage = tms.tms_utime + tms.tms_stime;
if (prev_clock)
if (prev_clock && curr_clock != prev_clock)
{
variable_data->available = TRUE;
variable_data->value.percentage = (gdouble) (curr_usage - prev_usage) /
@ -1701,7 +1701,7 @@ gimp_dashboard_sample_cpu_usage (GimpDashboard *dashboard,
curr_usage += ((guint64) process_user_time.dwHighDateTime << 32) |
(guint64) process_user_time.dwLowDateTime;
if (prev_time)
if (prev_time && curr_time != prev_time)
{
variable_data->available = TRUE;
variable_data->value.percentage = (gdouble) (curr_usage - prev_usage) /