gdk_widget_modify_bg & deadlock
- From: Bethany Seeger <seeger prosensing com>
- To: gtk-app-devel-list gnome org
- Subject: gdk_widget_modify_bg & deadlock
- Date: Wed, 06 Jun 2007 14:31:44 -0400
Hello,
I've got this code that seems to end up in dead lock, if I do something
to the gui, while it's calling gtk_widget_modify_bg.
---------
{
// events is an array of widget names
static GtkWidget *labels[NCONDS] = { NULL };
static unsigned int last=0xFFFFFFFF;
int i;
GdkColor yellow = {0,0xFFFF,0xFFFF,0};
if (!labels[0]) { /* Find our labels, the first time. */
for (i = 0; i < NCONDS; i++) {
labels[i] = lookup_widget(toplevel,events[i]);
}
}
/* Set the condition register widgets. */
if (cond != last) {
for (i = 0; i < NCONDS; i++) {
gdk_threads_enter();
if (cond & (1<<i)) {
gtk_widget_modify_bg(labels[i],GTK_STATE_NORMAL,&yellow);
} else {
gtk_widget_modify_bg(labels[i],GTK_STATE_NORMAL,NULL);
}
gdk_threads_leave();
}
last = cond;
}
}
----------
The threading has been properly initialized :
g_thread_init(NULL);
gdk_threads_init();
gtk_set_locale();
gtk_init(&argc,&argv);
...
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
The thread that's running the gtk_widget_modify_bg code was created from
the main thread before it went into the gtk_main().
So I understand that I've got a main thread in gtk_main, and another
thread running behind the scenes and updating the gui with user
changes.
If I try to change something in the gui (going to a new tab in a
notebook widget) while it's running the gtk_widget_modify_bg, the gui
will hang, like I've hit a deadlock condition. It happens to be the
page with the widget on it that the gtk_widget_modify_bg is on.
Would that be enough cause this condition? Any work arounds?
The kicker is that this works fine in linux (no deadlock) -- it only
deadlocks on a cross compiled windows exe.
Any advice would be greatly appreciated. I don't know the ins and outs
of gdk/gtk threading and can't tell if I'm doing something that's just
plain wrong.
Thanks,
Bethany
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]