Hello everyone,
I am stuck with my GTK app.
I want one callback to fire a new thread and to execute separately.
I use pthread_create() in the callback.
My problem is that when I recast the void* from the thread initial
function into a pointer to the object I need, the pointer is NULL, and
it segfaults when I write to it, obvious.
Any ideas?
Here are the bits of code that are concerned:
The event to catch:
static gint delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer
data)
{
lum_player_test(data);
return FALSE;
}
- I know the delete event is not the best one here but I need to learn
more about events as I don't manage to catch key events yet, pfff.
Here I create the new thread:
void lum_player_test(gpointer player)
{
pthread_create(&thread, NULL,
lum_player_play, player);
return;
}
and this is the function where the thread inits:
void *lum_player_play(gpointer ptr)
{
LumPlayer *player = NULL;
player = ptr;
[...]
- And there "player" is NULL, after the cast, I tried to cast the GTK
way or simple C way, like this
player = LUM_PLAYER(ptr);
or
player = (LumPlayer*) ptr;
But to no avail, "player" is NULL, ptr isn't though, when we enter the
function!
Is there a problem with shared resources? Strange, the actual "player"
object is declared as a global variable and initialized in the main and
never freed, so it should still be there.
It is the first time I use threads in C, this is probably not the way to
use them...
I 'd like to use gthreads but I cannot find doc about them, so I stick
to POSIX threads, this should not be the problem here.
What do you think?
BTW, this is an experiment to embed MPlayer into a gtk widget, directly.
Thanks for helping,
--
_ _ _
/ \ \ \
/ / \ \ \ (el greco)
\/_ | S \ Muy Mano,
| \/ / Muy Presa.
\_ K / http://users.aber.ac.uk/ssk01
\ \
Attachment:
signature.asc
Description: PGP signature