multithreaded gtk app
- From: Manu TM <manutm007 gmail com>
- To: GTK mailing list <gtk-app-devel-list gnome org>
- Subject: multithreaded gtk app
- Date: Wed, 20 Jan 2010 17:05:47 +0100
Hi everybody,
I'm having troubles debugging a multithreaded gtk app I made.
The app creates an animation in the main window by continuously
displaying a scrolled pixmap and uses its GUI to modify animation
parameters. The animated zone in the main window is updated by
g_timeout_add_full(..., handler, ...) and the timeout handler uses
gdk_draw_drawable() to draw on a gdk drawing area in the main
window.
The animation works fine but the app always crashes after opening a few
other windows (using the GUI) and I get either a segfault or this
pthread error:
Assertion 'pthread_setspecific(t->key, userdata) == 0' failed at
pulsecore/thread-posix.c:200, function pa_tls_set(). Aborting.
Basically, the app looks like this:
gint handler()
{
gdk_threads_enter();
if (...) {
/* display a different part of the pixmap each time */
gdk_draw_drawable(drawing_area, pixmap, parameters);
gdk_threads_leave;
return TRUE;
}
else {
< create a new pixmap>
g_timeout_add_full(..., delay, handler, ...);
gdk_threads_leave;
return FALSE;
}
}
int main(...)
{
...
if (!g_thread_supported())
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
gtk_init(&argc, &argv);
...
g_timeout_add_full(..., delay, handler, ...);
gtk_widget_show_all(...);
gtk_main();
gtk_threads_leave();
return 0;
}
To compile, I also have added these flags:
-g -D G_ERRORCHECK_MUTEXES `pkg-config --libs gtk+-2.0 gthread-2.0`
Did I made something wrong with gdk threads, or do I miss something or...?
Then the extra problem is I don't know much about multithread app debugging
(and I've already been searching the f****** web a lot!)
Any clue will be welcome because I'm a really stuck at the moment.
Thanks in advance.
Emmanuel Thomas-Maurin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]