Re: [gnome-love] Problem with Gtk.SpinButton.new_with_range



2013/4/28 Thiago Bellini Ribeiro <hackedbellini gmail com>:
Hi!

2 people send me error reports about this problem [1] when opening the
preferences dialog of my extension [2] on 3.8. One of them said he is
using Arch Linux with the latest updates.

The error says new_with_range is not a constructor.. But I'm confused.
That code worked fine (with totally no errors) from 3.4 to 3.6. Also,
when I was testing the extension on a virtual machine with a daily
build of fedora (to test 3.8), the preferences window worked (so, that
problem didn't exist there).

Also, I took a look at the 3.8's GtkSpinButton [3] documentation and
new_with_range is still a constructor.

new_with_range has never been a constructor, in the JS sense. It's a
regular function that returns a Gtk.SpinButton.

So, my question is: What is happening there? Does the js binding
changed? Should I change the syntax I'm using
(Gtk.SpinButton.new_with_range)? And why did the problem happened for
those guys and not for me (on my tests) and other people (I suppose I
would have received many more error reports if that was affecting
everyone)?

You're calling "new (Gtk.SpinButton.new_with_range)(...)" (parentheses
mine), i.e. creating an object whose class is
Gtk.SpinButton.new_with_range. That evaluates to:
- create an object
- invoke Gtk.SpinButton.new_with_range(...) with that object as this
  the call ignores the this object because it's not a method
- the return value is not undefined, discard the original object and
return the new one.

This is valid JS, after all, but it's obviously wrong: what you want
there is either
new Gtk.SpinButton({ adjustment: new Gtk.Adjustment(...) });
or
Gtk.SpinButton.new_with_range(...)
(without new)

Giovanni



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