From: Quy Tonthat Date: Tue, 6 Feb 2007 13:18:29 +0000 (+0000) Subject: Fix bug that causes crashes when click at the right of the track graph. X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/ecb510183ad77bf7ce7b3a4e2a25ed3364e928ed Fix bug that causes crashes when click at the right of the track graph. --- diff --git a/ChangeLog b/ChangeLog index 71cffa5c..94efd32a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-02-07 +Quy Tonthat : + * Fix bug that causes crashes when click at the right side (outside) + of the track graph area in the Track Poperties window. + 2007-02-06 Jocelyn Jaubert * Add new information to Track Properties. Postion in time will be diff --git a/src/viktrack.c b/src/viktrack.c index 5bc47c5b..dc87516f 100644 --- a/src/viktrack.c +++ b/src/viktrack.c @@ -641,6 +641,7 @@ VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdoub if ( tr->trackpoints ) { GList *iter = tr->trackpoints->next; + GList *last_iter = NULL; while (iter) { current_inc = vik_coord_diff ( &(VIK_TRACKPOINT(iter->data)->coord), @@ -648,8 +649,11 @@ VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdoub current_dist += current_inc; if ( current_dist >= dist ) break; + last_iter = iter; iter = iter->next; } + if (!iter) /* passing the end the track */ + return (last_iter ? last_iter->data : NULL); /* we've gone past the dist already, was prev trackpoint closer? */ /* should do a vik_coord_average_weighted() thingy. */ if ( iter->prev && abs(current_dist-current_inc-dist) < abs(current_dist-dist) )