From 9c515ee30bc2498ab3fa37d34dcc02d051a39e56 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Mon, 26 Jun 2000 05:29:04 +0000 Subject: Add some debugging messages to track down thread issues better and call GDK_THREAD_{LEAVE,ENTER} around the main loop as the GTK+ FAQ says we should do. svn path=/trunk/; revision=3737 --- mail/ChangeLog | 9 +++++++++ mail/mail-threads.c | 15 +++++++++++++++ mail/main.c | 2 ++ 3 files changed, 26 insertions(+) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 4baedbe444..90d5f5d9ed 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2000-06-26 Ettore Perazzoli + + * main.c (main): Call `GDK_THREADS_ENTER()' and + `GDK_THREADS_LEAVE()' around the main loop as in the examples from + the GTK+ FAQ. + + * mail-threads.c (DEBUG): New macro for debugging. + (read_msg): Use it. + 2000-06-25 Peter Williams * Makefile.am: Clean up the various _LIBS and _CFLAGS diff --git a/mail/mail-threads.c b/mail/mail-threads.c index 1df871719a..0905c401f5 100644 --- a/mail/mail-threads.c +++ b/mail/mail-threads.c @@ -29,6 +29,8 @@ #include "mail.h" #include "mail-threads.h" +#define DEBUG(p) g_print p + /* FIXME TODO: Do we need operations that don't get a progress window because * they're quick, but we still want camel to be locked? We need some kind * of flag to mail_operation_try, but then we also need some kind of monitor @@ -574,7 +576,9 @@ static void *dispatch_func( void *data ) msg.message = clur->prettyname; write( WRITER, &msg, sizeof( msg ) ); + GDK_THREADS_ENTER (); (clur->callback)( clur->data ); + GDK_THREADS_LEAVE (); msg.type = FINISHED; msg.func = clur->cleanup; /* NULL is ok */ @@ -625,39 +629,46 @@ static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer u switch( msg->type ) { case STARTING: + DEBUG (("*** Message -- STARTING\n")); gtk_label_set_text( GTK_LABEL( queue_window_message ), msg->message ); gtk_progress_bar_update( GTK_PROGRESS_BAR( queue_window_progress ), 0.0 ); g_free( msg ); break; case PERCENTAGE: + DEBUG (("*** Message -- PERCENTAGE\n")); gtk_progress_bar_update( GTK_PROGRESS_BAR( queue_window_progress ), msg->percentage ); g_free( msg ); break; case HIDE_PBAR: + DEBUG (("*** Message -- HIDE_PBAR\n")); gtk_progress_set_activity_mode( GTK_PROGRESS( queue_window_progress ), TRUE ); timeout_toggle( TRUE ); g_free( msg ); break; case SHOW_PBAR: + DEBUG (("*** Message -- SHOW_PBAR\n")); timeout_toggle( FALSE ); gtk_progress_set_activity_mode( GTK_PROGRESS( queue_window_progress ), FALSE ); g_free( msg ); break; case MESSAGE: + DEBUG (("*** Message -- MESSAGE\n")); gtk_label_set_text( GTK_LABEL( queue_window_message ), msg->message ); g_free( msg->message ); g_free( msg ); break; case PASSWORD: + DEBUG (("*** Message -- PASSWORD\n")); g_assert( msg->reply ); g_assert( msg->success ); get_password( msg ); /* don't free msg! done later */ break; case ERROR: + DEBUG (("*** Message -- ERROR\n")); show_error( msg ); g_free( msg ); break; @@ -667,14 +678,18 @@ static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer u */ case FINISHED: + DEBUG (("*** Message -- FINISH\n")); if( msg->func ) (msg->func)( msg->userdata ); if( op_queue == NULL ) { + g_print("\tNo more ops -- hide %p.\n", queue_window); /* All done! */ gtk_widget_hide( queue_window ); mail_operation_in_progress = FALSE; } else { + g_print("\tOperation left.\n"); + /* There's another operation left */ /* Pop it off the front */ diff --git a/mail/main.c b/mail/main.c index 5332213147..143277c854 100644 --- a/mail/main.c +++ b/mail/main.c @@ -79,7 +79,9 @@ main (int argc, char *argv []) component_factory_init (); + GDK_THREADS_ENTER (); bonobo_main (); + GDK_THREADS_LEAVE (); return 0; } -- cgit v1.2.3