Fix for error in pan-prediction 24/120124/2
authorTom Robinson <tom.robinson@samsung.com>
Tue, 27 Oct 2015 18:42:40 +0000 (18:42 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Tue, 21 Mar 2017 14:24:45 +0000 (07:24 -0700)
This is to resolve an issue reported by valgrind:

==7892==
==7892== Invalid read of size 4
==7892==    at 0x4B5C7BA: operator-= (vector2.h:196)
==7892==    by 0x4B5C7BA: Dali::Vector2::operator-(Dali::Vector2 const&) const (vector2.h:184)
==7892==    by 0x4B912BF: Dali::Internal::SceneGraph::PanGesture::InterpolatePoint(std::vector<Dali::Internal::SceneGraph::PanGesture::PanInfo, std::allocator<Dali::Internal::SceneGraph::PanGesture::PanInfo> >&, unsigned int, unsigned int, unsigned int, Dali::Internal::SceneGraph::PanGesture::PanInfo&, Dali::Internal::SceneGraph::PanGesture::RelativeVectors&, int, bool) (scene-graph-pan-gesture.cpp:947)

Change-Id: I99e494a5859df175109dc9cf74cf2ad1c7aecbd9
Signed-off-by: Tom Robinson <tom.robinson@samsung.com>
dali/internal/update/gestures/scene-graph-pan-gesture.cpp

index 5a3e2a2..9ec3f2a 100644 (file)
@@ -893,6 +893,7 @@ bool PanGesture::InterpolatePoint( PanInfoHistory& history, unsigned int current
   PanInfoHistoryIter historyBegin = history.begin();
   PanInfoHistoryIter lastIt = history.end();
   bool pointGenerated = false;
+  bool havePreviousPoint = false;
   RelativeVectors newAcceleration;
 
   // Iterate through point history to perform interpolation.
@@ -939,7 +940,7 @@ bool PanGesture::InterpolatePoint( PanInfoHistory& history, unsigned int current
       divisor += 1.0f / timeDelta;
 
       // Acceleration requires a previous point.
-      if( lastIt != history.end() )
+      if( havePreviousPoint )
       {
         // Time delta of input.
         float timeDifference( GetDivisibleTimeDifference( it->time, lastIt->time, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
@@ -949,6 +950,10 @@ bool PanGesture::InterpolatePoint( PanInfoHistory& history, unsigned int current
 
         accelerationDivisor += 1.0f / timeDelta;
       }
+      else
+      {
+        havePreviousPoint = true;
+      }
 
       tapsUsed++;
       lastIt = it;