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
This commit is contained in:
Sylvain Becker 2019-08-22 10:15:33 +02:00
parent 05f35c2420
commit 2937317f12
1 changed files with 6 additions and 4 deletions

View File

@ -335,7 +335,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
} }
/* DollarPath contains raw points, plus (possibly) the calculated length */ /* 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; int i;
float interval; float interval;
@ -381,7 +381,9 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
dist += d; dist += d;
} }
if (numPoints < DOLLARNPOINTS-1) { if (numPoints < DOLLARNPOINTS-1) {
SDL_SetError("ERROR: NumPoints = %i", numPoints); if (is_recording) {
SDL_SetError("ERROR: NumPoints = %i", numPoints);
}
return 0; return 0;
} }
/* copy the last point */ /* 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)); SDL_memset(points, 0, sizeof(points));
dollarNormalize(path,points); dollarNormalize(path, points, SDL_FALSE);
/* PrintPath(points); */ /* PrintPath(points); */
*bestTempl = -1; *bestTempl = -1;
@ -576,7 +578,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
#if defined(ENABLE_DOLLAR) #if defined(ENABLE_DOLLAR)
if (inTouch->recording) { if (inTouch->recording) {
inTouch->recording = SDL_FALSE; inTouch->recording = SDL_FALSE;
dollarNormalize(&inTouch->dollarPath,path); dollarNormalize(&inTouch->dollarPath, path, SDL_TRUE);
/* PrintPath(path); */ /* PrintPath(path); */
if (recordAll) { if (recordAll) {
index = SDL_AddDollarGesture(NULL,path); index = SDL_AddDollarGesture(NULL,path);