Re: float params of a gobject



On Mon, Jul 10, 2006 at 12:45:46PM -0300, Daniel Alonso wrote:
Hi, I'm trying to define a gobject class with a floating number
property. In the init class procedure I define the property the
following way:

      param_spec = g_param_spec_float
              ("width" /* name */,
               _("Icon Width") /* nick */,
               _("The width of the svg icon") /* blurb */,
               G_MINFLOAT /* minimum */,
               G_MAXFLOAT /* maximum */,
               0.0 /* default_value */,
               (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (g_object_class,
                                      PROP_WIDTH,
                                      param_spec);

This compiles fine, but when running the test program it raises a glib
exception:

(test:5073): GLib-GObject-CRITICAL **: g_param_spec_float: assertion
`default_value >= minimum && default_value <= maximum' failed

(test:5073): GLib-GObject-CRITICAL **: g_object_class_install_property:
assertion `G_IS_PARAM_SPEC (pspec)' failed

But default value 0.0 is equal G_MINFLOAT and lesser than G_MAXFLOAT,
isn't it? 

G_MINFLOAT is the minimum *positive* value a float can take,
so it's larger than 0.0.

Yeti


--
Anonyms eat their boogers.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]