title: GTK3 Passing Struct to Callback Function - Exception has occurred, segmentation error
body: <p>I have created a structure, outside of any functions:</p>
  <pre class="lang-c prettyprint-override"><code>//create structure
  typedef struct _LabelPointers
  {
      GtkWidget *readstringslabel;
      GtkWidget *snoteslabel;
      GtkWidget *fnoteslabel;
      GtkWidget *genericnoteslabel;
      GtkWidget *tabslabel;
      GtkWidget *chordslabel;
  } MyLabelPointers;
  </code></pre>
  <p>Then, I have created a structure, inside calling function, of labels:</p>
  <pre class="lang-c prettyprint-override"><code>//create structure of widget label pointers (to be passed to functions)
  MyLabelPointers labelpointers;
      
  labelpointers.readstringslabel = gtk_label_new(&quot;0&quot;);
  labelpointers.snoteslabel = gtk_label_new(&quot;0&quot;);
  labelpointers.fnoteslabel = gtk_label_new(&quot;0&quot;);
  labelpointers.genericnoteslabel = gtk_label_new(&quot;0&quot;);
  labelpointers.tabslabel = gtk_label_new(&quot;0&quot;);
  labelpointers.chordslabel = gtk_label_new(&quot;0&quot;);
  </code></pre>
  <p>Then, I have connected the callback as follows, passing <code>&amp;labelpointers</code>:</p>
  <pre class="lang-c prettyprint-override"><code>g_signal_connect(G_OBJECT (window), &quot;key_press_event&quot;,G_CALLBACK(pressspacebar), &amp;labelpointers);
  </code></pre>
  <p>The called function is as follows, accepting <code>*labelpointers</code>:</p>
  <pre class="lang-c prettyprint-override"><code>gboolean pressspacebar (GtkWidget *widget, GdkEventKey *event,  MyLabelPointers *lpointers) 
  </code></pre>
  <p>I then try to update the text in <code>labelpointers-&gt;readstringslabel</code> as in:</p>
  <pre class="lang-c prettyprint-override"><code>gtk_label_set_text(GTK_LABEL(lpointers-&gt;readstringslabel), cdata);
  </code></pre>
  <p>or as in:</p>
  <pre class="lang-c prettyprint-override"><code>gtk_label_set_text(GTK_LABEL(lpointers-&gt;readstringslabel), &quot;NEW DATA&quot;);
  </code></pre>
  <p>And it all compiles, and runs, until I get &quot;Exception has occurred, segmentation error&quot;. Just before the error, I print to shell as follows:</p>
  <pre class="lang-cpp prettyprint-override"><code>cout&lt;&lt;&quot;before\n&quot;;
  cout&lt;&lt;&quot;lpointers.readstringslabel = &quot;&lt;&lt;lpointers-&gt;readstringslabel&lt;&lt;&quot;\n&quot;;
  cout&lt;&lt;&quot;lpointers.readstringslabel = &quot;&lt;&lt;&amp;lpointers-&gt;readstringslabel&lt;&lt;&quot;\n&quot;;
  cout&lt;&lt;&quot;type = &quot; &lt;&lt; typeid(lpointers-&gt;readstringslabel).name() &lt;&lt; &quot;\n&quot;;
  </code></pre>
  <p>and get:</p>
  <pre><code>before
  lpointers.readstringslabel = 0x4
  lpointers.readstringslabel = 0x7fffffffd570
  type = P10_GtkWidget
  </code></pre>
  <p>I hope that this is enough information for someone to help me with this problem on which I've been working now for three days. Unfortunately, even Google hasn't been much help in leading me out of this.</p>