title: Gtk: Gtk-CRITICAL **:gtk_spin_button_get_value_as_int: assertion 'GTK_IS_SPIN_BUTTON (spin_button)' failed
body: <p>The GUI itself starts up normal. Everytime a Button is pressed a function is called which speaks to DAC's over SPI. The Error appears if a Button is pressed and the function <code>gtk_spin_button_get_value_as_int()</code> returns 0.
  But the Button itself works.</p>
  
  <p>The Error message:</p>
  
  <blockquote>
    <p>Gtk-CRITICAL **:gtk_spin_button_get_value_as_int: assertion 'GTK_IS_SPIN_BUTTON (spin_button)'</p>
  </blockquote>
  
  <p>Here is my sourcecode:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;wiringPi.h&gt;
  #include&lt;gtk/gtk.h&gt;
  
  #define SPAM 1
  
  #define SPIDELAY 500
  
  
  #define CPLDSPEED 500000
  #define DACSPEED 500000
  
  
  GtkWidget *g_lbl_hello;
  GtkWidget *g_lbl_count;
  GtkWidget *spin1,*spin2,*spin3,*spin4,*spin5;
  int channel1,dac1=0;
  int channel2,dac2=0;
  int channel3,dac3=0;
  int channel4,dac4=0;
  int dac5=0;
  
  //Konvertierung der Adresse zum Sendeformat
  char createAdress(int channel,int dac){
      char aout;
      int test;
      test=(channel*16)+dac;
      aout=(channel*16)+dac;
      printf("\n\nAdeDEC:%i\n",test);
      printf("Adresse:Fx%0x\n\n",aout);
      return aout;
  }
  
  //Kovertierung des DACWertes zum Sendeformmat
  char *createValue(short dacvalue){
  
      static char vout[1];
      vout[1]=dacvalue &amp; 0xFF;
      vout[0]=dacvalue&gt;&gt;8;
      printf("\n\nWert:Fx%02x%02x\n\n",vout[0],vout[1]);
      return vout;
  }
  
  void write_dac(int value,int dac,int channel){
      //Sendeformat der Adresse
      unsigned char a[0];
      printf("Schalte CS fÃ¼r DAC%i%i LOW\n",channel,dac);
          a[0]=createAdress(channel,dac);
          wiringPiSPIDataRW(0,a,1);
  
  
      printf("Schreibe Wert %hu auf den DAC%i%i",value,channel,dac);
      wiringPiSPIDataRW(1,createValue(value),2);
  
      printf("Schalte CS fÃ¼r DAC%i%i HIGH\n",channel,dac);
          a[0]=0x00;
          wiringPiSPIDataRW(0,a,1);
  
  }
  
  
  int main(int argc, char *argv[]){
  
      //Sendeformat des DAC-Wertes
      unsigned char *v;
  
      //Zwischenspeicher fÃ¼r die Daten
      unsigned short value;
      int channel,dac, spilocj=0;
          //SPI Setup
          wiringPiSetup();
      //Kommunikation mit CPLD wird eingerichtet
          if (wiringPiSPISetup(0,CPLDSPEED)==-1)
          {
                  printf("Du hast was falsch gemacht beim CPLDSPI\n");
          }
  
      //Kommunikation mit DAC wird eingerichtet
          if (wiringPiSPISetup(1,DACSPEED)==-1)
          {
                  printf("Du hast was falsch gemacht beim DACSPI\n");
          }
  
  
      GtkBuilder      *builder;
      GtkWidget       *window;
  
      gtk_init(&amp;argc, &amp;argv);
  
      builder = gtk_builder_new();
      gtk_builder_add_from_file (builder, "Testgui.glade", NULL);
  
      window = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
      gtk_builder_connect_signals(builder, NULL);
  
      g_object_unref(builder);
  
      gtk_widget_show(window);
      gtk_main();
  
      return 0;
  }
  
  void prg_dac1(){
      write_dac(gtk_spin_button_get_value_as_int(spin1),1,2);
  }
  
  void prg_dac2(){
      write_dac(gtk_spin_button_get_value_as_int(spin2),2,2);
  }
  
  void prg_dac3(){
      write_dac(gtk_spin_button_get_value_as_int(spin3),3,2);
  }
  
  void prg_dac4(){
      write_dac(gtk_spin_button_get_value_as_int(spin4),4,2);
  }
  
  void prg_dac5(){
      write_dac(gtk_spin_button_get_value_as_int(spin5),5,2);
  }
  </code></pre>
  
  <p>And here is my Gladeproject saved as GtkBuilder file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;interface&gt;
    &lt;!-- interface-requires gtk+ 3.0 --&gt;
    &lt;object class="GtkAdjustment" id="dacwerte1"&gt;
      &lt;property name="upper"&gt;65535&lt;/property&gt;
      &lt;property name="step_increment"&gt;1&lt;/property&gt;
      &lt;property name="page_increment"&gt;10&lt;/property&gt;
    &lt;/object&gt;
    &lt;object class="GtkAdjustment" id="dacwerte2"&gt;
      &lt;property name="upper"&gt;65535&lt;/property&gt;
      &lt;property name="step_increment"&gt;1&lt;/property&gt;
      &lt;property name="page_increment"&gt;10&lt;/property&gt;
    &lt;/object&gt;
    &lt;object class="GtkAdjustment" id="dacwerte3"&gt;
      &lt;property name="upper"&gt;65535&lt;/property&gt;
      &lt;property name="step_increment"&gt;1&lt;/property&gt;
      &lt;property name="page_increment"&gt;10&lt;/property&gt;
    &lt;/object&gt;
    &lt;object class="GtkAdjustment" id="dacwerte4"&gt;
      &lt;property name="upper"&gt;65535&lt;/property&gt;
      &lt;property name="step_increment"&gt;1&lt;/property&gt;
      &lt;property name="page_increment"&gt;10&lt;/property&gt;
    &lt;/object&gt;
    &lt;object class="GtkAdjustment" id="dacwerte5"&gt;
      &lt;property name="upper"&gt;65535&lt;/property&gt;
      &lt;property name="step_increment"&gt;1&lt;/property&gt;
      &lt;property name="page_increment"&gt;10&lt;/property&gt;
    &lt;/object&gt;
    &lt;object class="GtkWindow" id="window1"&gt;
      &lt;property name="can_focus"&gt;False&lt;/property&gt;
      &lt;child&gt;
        &lt;object class="GtkGrid" id="grid2"&gt;
          &lt;property name="visible"&gt;True&lt;/property&gt;
          &lt;property name="can_focus"&gt;False&lt;/property&gt;
          &lt;child&gt;
            &lt;object class="GtkLabel" id="label5"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="label" translatable="yes"&gt;DAC2&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;1&lt;/property&gt;
              &lt;property name="top_attach"&gt;1&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkLabel" id="label6"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="label" translatable="yes"&gt;DAC3&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;2&lt;/property&gt;
              &lt;property name="top_attach"&gt;1&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkLabel" id="label7"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="label" translatable="yes"&gt;DAC4&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;3&lt;/property&gt;
              &lt;property name="top_attach"&gt;1&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkLabel" id="label8"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="label" translatable="yes"&gt;DAC5&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;4&lt;/property&gt;
              &lt;property name="top_attach"&gt;1&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkButton" id="button1"&gt;
              &lt;property name="label" translatable="yes"&gt;button&lt;/property&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="receives_default"&gt;True&lt;/property&gt;
              &lt;signal name="clicked" handler="prg_dac1" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;0&lt;/property&gt;
              &lt;property name="top_attach"&gt;3&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkButton" id="button2"&gt;
              &lt;property name="label" translatable="yes"&gt;button&lt;/property&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="receives_default"&gt;True&lt;/property&gt;
              &lt;signal name="clicked" handler="prg_dac2" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;1&lt;/property&gt;
              &lt;property name="top_attach"&gt;3&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkButton" id="button3"&gt;
              &lt;property name="label" translatable="yes"&gt;button&lt;/property&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="receives_default"&gt;True&lt;/property&gt;
              &lt;signal name="clicked" handler="prg_dac3" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;2&lt;/property&gt;
              &lt;property name="top_attach"&gt;3&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkButton" id="button4"&gt;
              &lt;property name="label" translatable="yes"&gt;button&lt;/property&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="receives_default"&gt;True&lt;/property&gt;
              &lt;signal name="clicked" handler="prg_dac4" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;3&lt;/property&gt;
              &lt;property name="top_attach"&gt;3&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkButton" id="button5"&gt;
              &lt;property name="label" translatable="yes"&gt;button&lt;/property&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="receives_default"&gt;True&lt;/property&gt;
              &lt;signal name="clicked" handler="prg_dac5" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;4&lt;/property&gt;
              &lt;property name="top_attach"&gt;3&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkToolbar" id="toolbar1"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="toolbar_style"&gt;icons&lt;/property&gt;
              &lt;property name="icon_size"&gt;10&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;0&lt;/property&gt;
              &lt;property name="top_attach"&gt;0&lt;/property&gt;
              &lt;property name="width"&gt;5&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkLabel" id="DAC"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;False&lt;/property&gt;
              &lt;property name="label" translatable="yes"&gt;DAC1&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;0&lt;/property&gt;
              &lt;property name="top_attach"&gt;1&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkSpinButton" id="spin1"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="max_length"&gt;5&lt;/property&gt;
              &lt;property name="invisible_char"&gt;●&lt;/property&gt;
              &lt;property name="activates_default"&gt;True&lt;/property&gt;
              &lt;property name="width_chars"&gt;10&lt;/property&gt;
              &lt;property name="invisible_char_set"&gt;True&lt;/property&gt;
              &lt;property name="adjustment"&gt;dacwerte1&lt;/property&gt;
              &lt;property name="climb_rate"&gt;1&lt;/property&gt;
              &lt;property name="update_policy"&gt;if-valid&lt;/property&gt;
              &lt;signal name="editing-done" handler="set_dac1" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;0&lt;/property&gt;
              &lt;property name="top_attach"&gt;2&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkSpinButton" id="spin5"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="max_length"&gt;5&lt;/property&gt;
              &lt;property name="invisible_char"&gt;●&lt;/property&gt;
              &lt;property name="width_chars"&gt;10&lt;/property&gt;
              &lt;property name="invisible_char_set"&gt;True&lt;/property&gt;
              &lt;property name="adjustment"&gt;dacwerte5&lt;/property&gt;
              &lt;property name="climb_rate"&gt;0.02&lt;/property&gt;
              &lt;property name="numeric"&gt;True&lt;/property&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;4&lt;/property&gt;
              &lt;property name="top_attach"&gt;2&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkSpinButton" id="spin4"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="max_length"&gt;5&lt;/property&gt;
              &lt;property name="invisible_char"&gt;●&lt;/property&gt;
              &lt;property name="width_chars"&gt;10&lt;/property&gt;
              &lt;property name="invisible_char_set"&gt;True&lt;/property&gt;
              &lt;property name="adjustment"&gt;dacwerte4&lt;/property&gt;
              &lt;signal name="editing-done" handler="set_dac4" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;3&lt;/property&gt;
              &lt;property name="top_attach"&gt;2&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkSpinButton" id="spin3"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="max_length"&gt;5&lt;/property&gt;
              &lt;property name="invisible_char"&gt;●&lt;/property&gt;
              &lt;property name="width_chars"&gt;10&lt;/property&gt;
              &lt;property name="invisible_char_set"&gt;True&lt;/property&gt;
              &lt;property name="adjustment"&gt;dacwerte3&lt;/property&gt;
              &lt;property name="update_policy"&gt;if-valid&lt;/property&gt;
              &lt;signal name="editing-done" handler="set_dac3" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;2&lt;/property&gt;
              &lt;property name="top_attach"&gt;2&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
          &lt;child&gt;
            &lt;object class="GtkSpinButton" id="spin2"&gt;
              &lt;property name="visible"&gt;True&lt;/property&gt;
              &lt;property name="can_focus"&gt;True&lt;/property&gt;
              &lt;property name="max_length"&gt;5&lt;/property&gt;
              &lt;property name="invisible_char"&gt;●&lt;/property&gt;
              &lt;property name="width_chars"&gt;10&lt;/property&gt;
              &lt;property name="invisible_char_set"&gt;True&lt;/property&gt;
              &lt;property name="input_purpose"&gt;number&lt;/property&gt;
              &lt;property name="adjustment"&gt;dacwerte2&lt;/property&gt;
              &lt;property name="wrap"&gt;True&lt;/property&gt;
              &lt;signal name="editing-done" handler="set_dac2" swapped="no"/&gt;
            &lt;/object&gt;
            &lt;packing&gt;
              &lt;property name="left_attach"&gt;1&lt;/property&gt;
              &lt;property name="top_attach"&gt;2&lt;/property&gt;
              &lt;property name="width"&gt;1&lt;/property&gt;
              &lt;property name="height"&gt;1&lt;/property&gt;
            &lt;/packing&gt;
          &lt;/child&gt;
        &lt;/object&gt;
      &lt;/child&gt;
    &lt;/object&gt;
    &lt;object class="GtkWindowGroup" id="windowgroup1"/&gt;
  &lt;/interface&gt;
  </code></pre>
  
  <p>In addation I get a compilation warning about the datatypes regarding the <code>GtkWidget</code> pointers <code>spin1</code> etc. . But changing the datatype to the appropriate one <code>GtkSpinButton</code> does not help either.</p>
  
  <blockquote>
    <p>main.c: In function ‘prg_dac1’: main.c:116:45: warning: passing
    argument 1 of ‘gtk_spin_button_get_value_as_int’ from incompatible
    pointer type   write_dac(gtk_spin_button_get_value_as_int(spin1),1,2);
                                                 ^ In file included from /usr/include/gtk-3.0/gtk/gtk.h:185:0,
                     from main.c:4: /usr/include/gtk-3.0/gtk/gtkspinbutton.h:194:7: note: expected ‘struct
    GtkSpinButton *’ but argument is of type ‘struct GtkWidget *’  gint 
    gtk_spin_button_get_value_as_int   (GtkSpinButton  *spin_button);</p>
  </blockquote>