Made Timer#initialize reject infinite floats for the interval.
[ruby-ecore.git] / src / ecore / rb_timer.c
index 939a88d9df91c8a64a0f8e5790ad10b107255d31..6ef4d75c06d2a26b1240db3bf7fd95d8b8c9cc03 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: rb_timer.c 351 2006-02-10 15:25:40Z tilman $
- *
  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
@@ -86,6 +84,11 @@ static VALUE c_init (VALUE self, VALUE interval)
        if (!rb_block_given_p ())
                rb_raise (rb_eStandardError, "block missing");
 
+       interval = rb_funcall2 (interval, rb_intern ("to_f"), 0, NULL);
+
+       if (rb_funcall2 (interval, rb_intern ("finite?"), 0, NULL) == Qfalse)
+               rb_raise (rb_eArgError, "Argument must not be infinite");
+
        timer->callback = rb_block_proc ();
        timer->deleted = false;
        timer->real = ecore_timer_add (NUM2DBL (interval),