Commit 2937317f12e3490bc3eb8fe228d2c3019edd0c79

Sylvain Becker 2019-08-22T10:15:33

Fixed bug 4172 - remove logging Gesture error "NumPoints = 0" - not necessary when app isn't recording gesture. - happen when gesture path has less than 2 different points

diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c
index 558a96f..0f5fc81 100644
--- a/src/events/SDL_gesture.c
+++ b/src/events/SDL_gesture.c
@@ -335,7 +335,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
 }
 
 /* DollarPath contains raw points, plus (possibly) the calculated length */
-static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
+static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SDL_bool is_recording)
 {
     int i;
     float interval;
@@ -381,7 +381,9 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
         dist += d;
     }
     if (numPoints < DOLLARNPOINTS-1) {
-        SDL_SetError("ERROR: NumPoints = %i", numPoints);
+        if (is_recording) {
+            SDL_SetError("ERROR: NumPoints = %i", numPoints);
+        }
         return 0;
     }
     /* copy the last point */
@@ -435,7 +437,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu
 
     SDL_memset(points, 0, sizeof(points));
 
-    dollarNormalize(path,points);
+    dollarNormalize(path, points, SDL_FALSE);
 
     /* PrintPath(points); */
     *bestTempl = -1;
@@ -576,7 +578,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
 #if defined(ENABLE_DOLLAR)
             if (inTouch->recording) {
                 inTouch->recording = SDL_FALSE;
-                dollarNormalize(&inTouch->dollarPath,path);
+                dollarNormalize(&inTouch->dollarPath, path, SDL_TRUE);
                 /* PrintPath(path); */
                 if (recordAll) {
                     index = SDL_AddDollarGesture(NULL,path);