]> git.street.me.uk Git - andy/viking.git/commitdiff
Fix bug that causes crashes when click at the right of the track graph.
authorQuy Tonthat <qtonthat@gmail.com>
Tue, 6 Feb 2007 13:18:29 +0000 (13:18 +0000)
committerQuy Tonthat <qtonthat@gmail.com>
Tue, 6 Feb 2007 13:18:29 +0000 (13:18 +0000)
ChangeLog
src/viktrack.c

index 71cffa5ca92f11fb384db43358f02801274b589a..94efd32adc3b2edb78dcb761f630f0017b929f8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-07
+Quy Tonthat <qtonthat@gmail.com>:
+       * 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 <jocelyn.jaubert@gmail.com>
        * Add new information to Track Properties. Postion in time will be
index 5bc47c5beeb61399f305b45f31aba7a4b56e093a..dc87516f3d185983ac260bb725d078dfcfee2b21 100644 (file)
@@ -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) )