]> err.no Git - libchamplain/commitdiff
Catch an arithmetic exception (division by 0)
authorEmmanuel Rodriguez <emmanuel.rodriguez@booking.com>
Fri, 31 Jul 2009 18:34:03 +0000 (20:34 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 1 Aug 2009 19:22:09 +0000 (15:22 -0400)
tidy/tidy-finger-scroll.c

index d404d72b09c663e640afcf24ae76542b2c1451ca..f57f379d48b2ab2ee20d2bfb32a56be58b006c06 100644 (file)
@@ -428,6 +428,18 @@ button_release_event_cb (ClutterActor *actor,
           frac = clutter_qdivx (CLUTTER_FLOAT_TO_FIXED (time_diff/1000.0),
                                 CLUTTER_FLOAT_TO_FIXED (1000.0/60.0));
           
+          /* On a macbook that's running Ubuntu 9.04 sometimes frac is 0 and
+             this causes a division by 0. Here we try to avoid that.
+           */
+          if (frac == 0)
+            {
+                g_print ("Caught a division by 0 (%d / %d).\n",
+                    CLUTTER_FLOAT_TO_FIXED (time_diff/1000.0),
+                    CLUTTER_FLOAT_TO_FIXED (1000.0/60.0)
+                );
+                clutter_event_put ((ClutterEvent *)event);
+                return TRUE;
+            }
           /* See how many units to move in 1/60th of a second */
           priv->dx = CLUTTER_UNITS_FROM_FIXED(clutter_qdivx (
                      CLUTTER_UNITS_TO_FIXED(x_origin - x), frac));