[libchamplain] Catch an arithmetic exception (division by 0)
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Catch an arithmetic exception (division by 0)
- Date: Sat, 1 Aug 2009 19:43:52 +0000 (UTC)
commit a9ffbb0ed51384ef44886456bc879d01b64702b1
Author: Emmanuel Rodriguez <emmanuel rodriguez booking com>
Date: Fri Jul 31 20:34:03 2009 +0200
Catch an arithmetic exception (division by 0)
tidy/tidy-finger-scroll.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/tidy/tidy-finger-scroll.c b/tidy/tidy-finger-scroll.c
index d404d72..f57f379 100644
--- a/tidy/tidy-finger-scroll.c
+++ b/tidy/tidy-finger-scroll.c
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]