Skip to content

Instantly share code, notes, and snippets.

@loentar
Last active October 25, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loentar/30c375f091967a98575c to your computer and use it in GitHub Desktop.
Save loentar/30c375f091967a98575c to your computer and use it in GitHub Desktop.
diff --git a/gui/freehand.py b/gui/freehand.py
index a9b4c64..7a3f81f 100644
--- a/gui/freehand.py
+++ b/gui/freehand.py
@@ -10,6 +10,7 @@
## Imports
import math
+from sys import float_info
from numpy import array
from numpy import isfinite
from lib.helpers import clamp
@@ -41,6 +42,7 @@ EVCOMPRESSION_WORKAROUND_DISABLE_VIA_API = 1
EVCOMPRESSION_WORKAROUND_EVHACK_FILTER = 2
EVCOMPRESSION_WORKAROUND_NONE = 999
+MAX_SQR = math.sqrt(float_info.max)
## Class defs
@@ -510,7 +512,7 @@ class FreehandMode (gui.mode.BrushworkModeMixin,
# Check whether tilt is present. For some tablets without
# tilt support GTK reports a tilt axis with value nan, instead
# of None. https://gna.org/bugs/?17084
- if xtilt is None or ytilt is None or not isfinite(xtilt+ytilt):
+ if xtilt is None or ytilt is None or not isfinite(xtilt+ytilt) or xtilt >= MAX_SQR or ytilt >= MAX_SQR or xtilt <= -MAX_SQR or ytilt <= -MAX_SQR:
xtilt = 0.0
ytilt = 0.0
else:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment