Re: Re: Should I use Gtk+ or GUI?



Hi,

I have resolved this problem after add gdk_threads_*() to all timer callback functions as following :

   gdk_threads_enter();

   .....
   .....
gdk_threads_leave();

Regards
 Rill
//------------------------------------------
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

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]