From 8c939442eb198a437047a8684eeea0b5071bdf3f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 16 Aug 2016 22:38:36 +0100 Subject: [PATCH] Fix issue in display of maximum speed when there is no speed. Ensure buffer contents is reset in case there is nothing to display. Also align code in mph block to be as per other speed units. --- src/viktrwlayer_analysis.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/viktrwlayer_analysis.c b/src/viktrwlayer_analysis.c index 47e229e7..cfb09385 100644 --- a/src/viktrwlayer_analysis.c +++ b/src/viktrwlayer_analysis.c @@ -286,12 +286,16 @@ static void table_output ( track_stats ts, GtkWidget *content[] ) gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); // I'm sure this could be cleaner... + g_snprintf ( tmp_buf, sizeof(tmp_buf), "--" ); switch (a_vik_get_units_speed()) { case VIK_UNITS_SPEED_MILES_PER_HOUR: - g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.1f mph"), (double)VIK_MPS_TO_MPH(ts.max_speed) ); + if ( ts.max_speed > 0 ) + g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.1f mph"), (double)VIK_MPS_TO_MPH(ts.max_speed) ); gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); if ( ts.duration > 0 ) g_snprintf ( tmp_buf, sizeof(tmp_buf), ("%.1f mph"), (double)VIK_MPS_TO_MPH(ts.length/ts.duration) ); + else + g_snprintf ( tmp_buf, sizeof(tmp_buf), "--" ); break; case VIK_UNITS_SPEED_METRES_PER_SECOND: if ( ts.max_speed > 0 ) -- 2.39.5