Re: Warnings/Errors during Threaded Execution
- From: Havoc Pennington <hp redhat com>
- To: Mark Richardson <markmapo yahoo com>
- Cc: gtk-devel-list gnome org
- Subject: Re: Warnings/Errors during Threaded Execution
- Date: Thu, 30 Nov 2006 13:34:29 -0500
Mark Richardson wrote:
I'm guessing that you're accessing some widgets in a separate thread (or
in your callbacks). Whenever you do this, you need to lock the widgets
so that you're not modifying them while they are trying to be drawn. So
in a callback, you need
gdk_threads_leave();
// the code that is needed for the callback
gdk_threads_enter();
or, when you're in the thread that you started, you need to do the same
thing anytime that you're accessing widgets.
One last thing, in your main program, make sure that you do the following...
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
This way, the main loop runs correctly with threads.
I can't promise that this is the textbook example of how to work with
multithreads, but it's what I got working after many hours of trial & error.
There are docs on this, so it's not necessary to just try stuff ;-)
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html
also, the question here is more appropriate for gtk-list/gtk-app-devel-list
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]