Re: fetching unset GParamSpec property



muppet <scott asofyet org> writes:

I started to write "but that would render newSVGParamSpec_ornull()
obsolete", but then i looked at gperl.h and there is no such symbol.

Speaking of ornull, I struck another NULL, this time through a mistake.
It looks like g_param_spec_int() and friends return NULL when the
default is outside the min/max, so the following gets a segv.

    use strict;
    use warnings;
    use Gtk2;
    Glib::ParamSpec->int ('foo',
                          'foo',
                          'Blurb.',
                          -1, 0, 999,
                          Glib::G_PARAM_READWRITE);

It prints g_log warnings, then goes bang.  I guess there'd be a choice
between returning undef or croaking.  undef would be more like the C and
friendlier for the unlikely case of creating something dynamically.  Or
croaking would be a more usual way for a constructor to fail, and any
typical subclassing isn't going to get much further ...

-- 
The sigfile one-line movie reviews series:
"2001: A Space Odyssey" -- a documentary about apes.



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