Re: Should I use Gtk+ or even GUI?
- From: Jan Kratochvil <rcpt-gtk-devel-list AT gnome org jankratochvil net>
- To: jacky618 jacky618 <hhd618 hotmail com>
- Cc: gtk-devel-list gnome org
- Subject: Re: Should I use Gtk+ or even GUI?
- Date: Tue, 15 Feb 2005 12:41:02 +0100
Hi,
On Tue, 15 Feb 2005 12:05:03 +0100, jacky618 jacky618 wrote:
...
> gdk_threads_enter();
> gtk_clist_append(GTK_CLIST(Clist_CommStatus), &pText);
> gdk_flush();
> gdk_threads_leave();
...
> I have tried many times to get the program thread-safe. Unfortunately, the
> error "Xlib: unexpected async reply" still exists.So I feel the list
> control have fault . Is it true?
In such simple case you may just miss the initialization:
/* gdk_threads_init() must be called before gtk_init()!
* gtk_init() gets called by create_App() here.
*/
if (!g_thread_supported())
g_thread_init(NULL);
if (!gdk_threads_mutex)
gdk_threads_init();
Still in the December of 2003 I had serious problems with threading of GTK.
Finally I started using the single-threaded polling:
while (g_main_context_pending(NULL))
g_main_context_iteration(
NULL, /* context */
FALSE); /* may_block */
You can see the source
http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/src/install/acquire/ui-gnome.c?rev=HEAD
with the threads vs. polling conditional compilation:
/* Although proper GTK+ locking is provided below there are some
* bugs with compatibility of GTK+/Gnome-VFS/GConf.
* The main thread executes gtk_main()->g_main_loop_run()
* while the working thread initializes Gnome-VFS by GConf and
* executes also g_main_loop_run() while sharing some poll() fds.
*/
/* #define UI_GNOME_THREADS 1 */
I am sorry it was never Bugzilled and I never checked it with the recent Gnome
subsystems.
Regards,
Lace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]