On Wed, 27 Nov 2013 11:59:23 -0800 (PST)
David Buchan <pdbuc...@yahoo.com> wrote:
> Hi Michael,
> 
> My 32-bit, GTK+2 version does
> 
>   // Secure glib
>   if (!g_thread_supported ()) {
>     g_thread_init (NULL);
>   }
> 
> at the beginning, and then the thread is spawned via:
> 
> on_button1_clicked (GtkButton *button1, MyData *data)
> {
>   GThread *thread;
>   GError *error = NULL;
> 
>   thread = g_thread_create ((GThreadFunc) my_function, data, FALSE,
> &error); if (! thread) {
>       g_print ("Error: Unable to create new thread for my_function()
> in on_button1_clicked().%s\n", error->message); exit (EXIT_FAILURE);
>     }
> 
> My 64-bit, GTK+3 versions does not do the g_thread_init() call.
> 
> It spawns a new thread via:
> 
> int
> on_button1_clicked (GtkButton *button1, MyData *data)
> {
>   GThread *thread;
> 
>   thread = g_thread_new ("my_function", (GThreadFunc) my_function,
> data); if (! thread) {
>       fprintf (stderr, "Error: Unable to create new thread for
> my_function() in on_button1_clicked().\n"); exit (EXIT_FAILURE);
>     }

Show us your my_function(): you are almost certainly doing something
wrong. Best of all, provide a complete compilable example which
demonstrates the problem. And why are you casting the function pointer
to GThreadFunc?  You do not need to call g_thread_init() with glib >=
2.32, and you do with earlier versions. Prior to version 2.24
g_thread_init() had to be the first glib call. Between 2.24 and 2.30 it
had to be the first call relevant to threads.

Also, please don't top post.

Chris
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to