device: Guard against divisions by zero
The range of a device could be 0, so we need to bail out from the scaling during the axis translation. https://bugzilla.gnome.org/show_bug.cgi?id=707033
This commit is contained in:
parent
e90022f3c7
commit
fb8eacfb02
@ -46,6 +46,8 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-stage-private.h"
|
#include "clutter-stage-private.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -1218,6 +1220,9 @@ _clutter_input_device_translate_axis (ClutterInputDevice *device,
|
|||||||
info->axis == CLUTTER_INPUT_AXIS_Y)
|
info->axis == CLUTTER_INPUT_AXIS_Y)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (fabs (info->max_value - info->min_value) < 0.0000001)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
width = info->max_value - info->min_value;
|
width = info->max_value - info->min_value;
|
||||||
real_value = (info->max_axis * (value - info->min_value)
|
real_value = (info->max_axis * (value - info->min_value)
|
||||||
+ info->min_axis * (info->max_value - value))
|
+ info->min_axis * (info->max_value - value))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user