efl/gesture: avoid direct double access in structs

this is functionally wrong (the comparison fails) and also causes SIGBUS on
arm

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Reviewed-by: woochan lee <wc0917.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D11198
This commit is contained in:
Mike Blumenkrantz 2020-01-27 09:27:41 -05:00 committed by Marcel Hollerbach
parent 17995ee710
commit 3612467c4f
5 changed files with 20 additions and 18 deletions

View File

@ -45,7 +45,7 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
double length;
double length, start_timeout = pd->start_timeout;
double timeout = TAP_TIME_OUT;
Eina_Position2D pos;
Eina_Vector2 dist;
@ -54,7 +54,7 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
pd->target = watched;
pd->gesture = gesture;
if (!pd->start_timeout)
if (!EINA_DBL_NONZERO(start_timeout))
{
double time;
Eina_Value *val = _recognizer_config_get(obj, "glayer_double_tap_timeout");
@ -66,7 +66,7 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
}
}
else
timeout = pd->start_timeout;
timeout = start_timeout;
switch (efl_gesture_touch_state_get(event))
{

View File

@ -185,7 +185,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
double angle;
double angle, line_angle;
Eina_Value *val;
unsigned char glayer_continues_enable;
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
@ -258,12 +258,13 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
_vector_get(pd->st_line, efl_gesture_touch_cur_point_get(event),
&pd->line_length, &angle);
line_angle = pd->line_angle;
if (pd->t_st)
{
if (pd->line_angle >= 0.0)
if ((line_angle > 0.0) || EINA_DBL_EQ(line_angle, 0.0))
{
double line_distance_tolerance, line_angular_tolerance;
double a = fabs(angle - pd->line_angle);
double a = fabs(angle - line_angle);
double d = (tan(DEG2RAD(a))) * pd->line_length;
val = _recognizer_config_get(obj, "glayer_line_distance_tolerance");
@ -306,12 +307,12 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
line_min_length *= pd->finger_size;
if (pd->line_length >= line_min_length)
fd->angle = pd->line_angle = angle;
line_angle = fd->angle = pd->line_angle = angle;
}
if (pd->t_end)
{
if (pd->line_angle < 0.0)
if (line_angle < 0.0)
{
_reset_recognizer(pd);

View File

@ -44,7 +44,7 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
double length; // Manhattan distance
double length, start_timeout = pd->start_timeout; // Manhattan distance
double timeout = EFL_GESTURE_LONG_TAP_TIME_OUT;
Eina_Position2D pos;
Eina_Vector2 dist;
@ -53,7 +53,7 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
pd->target = watched;
pd->gesture = gesture;
if (!pd->start_timeout)
if (!EINA_DBL_NONZERO(start_timeout))
{
double time;
Eina_Value *val = _recognizer_config_get(obj, "glayer_long_tap_start_timeout");
@ -65,7 +65,7 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
}
}
else
timeout = pd->start_timeout;
timeout = start_timeout;
switch (efl_gesture_touch_state_get(event))
{

View File

@ -44,7 +44,7 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
Efl_Canvas_Gesture *gesture, Efl_Object *watched,
Efl_Canvas_Gesture_Touch *event)
{
double length;
double length, start_timeout = pd->start_timeout;
double timeout = TAP_TIME_OUT;
Eina_Position2D pos;
Eina_Vector2 dist;
@ -53,7 +53,7 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
pd->target = watched;
pd->gesture = gesture;
if (!pd->start_timeout)
if (!EINA_DBL_NONZERO(start_timeout))
{
double time;
Eina_Value *val = _recognizer_config_get(obj, "glayer_double_tap_timeout");
@ -65,7 +65,7 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
}
}
else
timeout = pd->start_timeout;
timeout = start_timeout;
switch (efl_gesture_touch_state_get(event))
{

View File

@ -76,7 +76,7 @@ _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
Evas_Coord yy2,
double zoom_finger_factor)
{
double rt = 1.0;
double rt = 1.0, zoom_distance_tolerance = pd->zoom_distance_tolerance;
//TODO: Enable below code if the zoom momentum is need
//unsigned int tm_end = (pd->zoom_mv.cur.timestamp > pd->zoom_mv1.cur.timestamp) ?
// pd->zoom_mv.cur.timestamp : pd->zoom_mv1.cur.timestamp;
@ -93,7 +93,7 @@ _zoom_compute(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd,
return zd->zoom;
}
if (pd->zoom_distance_tolerance) /* zoom tolerance <> ZERO, means
if (EINA_DBL_NONZERO(zoom_distance_tolerance)) /* zoom tolerance <> ZERO, means
* zoom action NOT started yet */
{
/* avoid jump with zoom value when break tolerance */
@ -147,6 +147,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
Efl_Canvas_Gesture_Zoom_Data *zd = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_ZOOM_CLASS);
Efl_Canvas_Gesture_Touch_Data *td = efl_data_scope_get(event, EFL_CANVAS_GESTURE_TOUCH_CLASS);
Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
double zoom_distance_tolerance = pd->zoom_distance_tolerance;
//FIXME: Wheel zoom test first here.
@ -164,7 +165,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
rd->continues = EINA_TRUE;
if (!pd->zoom_distance_tolerance && !pd->calc_temp)
if (!EINA_DBL_NONZERO(zoom_distance_tolerance) && !pd->calc_temp)
{
pd->calc_temp = EINA_TRUE;
val = _recognizer_config_get(obj, "glayer_zoom_distance_tolerance");
@ -239,7 +240,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
pd->zoom_mv.cur.pos.y, pd->zoom_mv1.cur.pos.x,
pd->zoom_mv1.cur.pos.y, pd->zoom_finger_factor);
if (!pd->zoom_distance_tolerance)
if (!EINA_DBL_NONZERO(zoom_distance_tolerance))
{
double d = zd->zoom - pd->next_step;