Re: Toolbar/Toolbox or something other...



        hmmm, is that really your "main" ?
or is it a function used to build the screen ?

I just have a hunch that the automatic variable
"test" in main isn't really around when "run"
runs. (but if "test" is really global than
it should still be at the same address).

but if &test is no longer a valid address
then a segfault is apropriate.

try declaring test like so:


gint *test = g_new(gint, 1);
*test = 99;



just for the hell of it ;)

        -Tristan


I'll show you what I tried:

int main (blabla)
{
  /* some lines cut... */
  GtkWidget *button;
  int test = 99;

  /* button - run */
  button = gtk_button_new_from_stock (GTK_STOCK_EXECUTE);
  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (run), (gpointer) entry);

  gtk_box_pack_start(GTK_BOX (box2), button, TRUE, TRUE, 5);

  g_object_set_data (G_OBJECT (button), "test", (gpointer) &test);
  result = (int*) g_object_get_data (G_OBJECT (button), "test");

  g_print ("result: %d\n", *result);                       /* this works
*/

  gtk_widget_show (button);
}

void run (GtkWidget *button, gpointer entry)
{
  int *result;
  result = (int*) g_object_get_data (G_OBJECT (button), "test");
  g_print ("result: %d\n", *result);          /* here: Segmentation
Fault */

  /* some lines cut */
}

I doesn't understand it. Perhaps it's only a silly pointer bug ;-)

Andreas
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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