]> git.street.me.uk Git - andy/viking.git/commitdiff
Fix issue in display of maximum speed when there is no speed.
authorRob Norris <rw_norris@hotmail.com>
Tue, 16 Aug 2016 21:38:36 +0000 (22:38 +0100)
committerRob Norris <rw_norris@hotmail.com>
Tue, 16 Aug 2016 21:39:41 +0000 (22:39 +0100)
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

index 47e229e7cd36b807a1dee619284e132b728ccd32..cfb09385399fe01749de233e1d0b909bc38a9ea2 100644 (file)
@@ -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 )