[Gtk-sharp-list] Gtk.SpinButton recursive signals create segfault

Fabian Sturm f@rtfs.org
Tue, 08 Mar 2005 20:00:49 +0100


I have some trouble with a Gtk.SpinButton and its signals.
A recursive call of the changed signal leads to a segfault.

I guess I should describe my class structure a little bit:
(all in pseudo code, I actually use glade to load the gui)

I have one class holding data

class data {
  public EventHandler Changed;
  private int number;

  public int Number
    get { return Number; }
    set { Number = value; OnChanged (); }

  void OnChanged () {
    if (Changed != null)
      Changed (this);

and one class creating a gui for this data

class gui {

  public void gui (data d, vbox v) {
    SpinButton number_sb = new SpinButton ();
    v.add (number_sb);
    // connect signal handler
    number_sb.Value = d.number;
    d.Changed = new EventHandler (OnDChanged);

  OnDChanged (data d) {
    number_sb.Value = d.name;

  on_name_entry_changed (object o, EventArgs args) {
    d.Number = ((SpinButton)o).ValueAsInt;

So the recursion is that If I click the up arrow on the SpinButton which
triggers an "on_number_sb_changed" signal which changes "d.Number = "
which triggers a Changed Event....

So is my class structure wrong? The reason why I seperated data and gui
is that I might have two different guis at the same time showing the
same data.

Hope anyone can help me with this. Btw. this is more a Gtk+ problem than
gtk-sharp but the solutions I got there using
g_signal_handlers_block_by_func() failed because I could not find this
method in the gtk# docu.

Btw. the recursion does not appear for Gtk.Entry widgets!?

Thanks a lot, Fabian