diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libsylph/imap.c | 5 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/query_search.c | 10 |
4 files changed, 27 insertions, 5 deletions
@@ -1,3 +1,10 @@ +2009-11-04 + + * libsylph/imap.c + src/query_search.c + src/main.c: fixed a bug that prohibited query search on IMAP + folders. Don't call gtk_main_iteration() from non-main threads. + 2009-11-02 * src/summaryview.c: summary_selection_changed(): fixed unintended diff --git a/libsylph/imap.c b/libsylph/imap.c index 16d13cc1..d39814c0 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -4244,6 +4244,7 @@ static gint imap_cmd_ok_real(IMAPSession *session, GPtrArray *argbuf) str = g_string_sized_new(256); + //g_usleep(800000); while ((ok = imap_cmd_gen_recv(session, &buf)) == IMAP_SUCCESS) { g_string_append(str, buf); @@ -4817,11 +4818,11 @@ static void imap_thread_run_proxy(gpointer push_data, gpointer data) { IMAPRealSession *real = (IMAPRealSession *)data; - g_print("imap_thread_run_proxy (%p): calling thread_func\n", g_thread_self()); + debug_print("imap_thread_run_proxy (%p): calling thread_func\n", g_thread_self()); real->retval = real->thread_func(IMAP_SESSION(real), real->thread_data); g_atomic_int_set(&real->flag, 1); - g_print("imap_thread_run_proxy (%p): thread_func done\n", g_thread_self()); g_main_context_wakeup(NULL); + debug_print("imap_thread_run_proxy (%p): thread_func done\n", g_thread_self()); } static gint imap_thread_run(IMAPSession *session, IMAPThreadFunc func, @@ -113,6 +113,10 @@ static gint lock_socket = -1; static gint lock_socket_tag = 0; static GIOChannel *lock_ch = NULL; +#if USE_THREADS +static GThread *main_thread; +#endif + static struct RemoteCmd { gboolean receive; gboolean receive_all; @@ -618,6 +622,11 @@ static void thread_leave_func(void) static void event_loop_iteration_func(void) { + if (g_thread_self() != main_thread) { + g_fprintf(stderr, "event_loop_iteration_func called from non-main thread (%p)\n", g_thread_self()); + g_usleep(10000); + return; + } gtk_main_iteration(); } #endif @@ -633,6 +642,7 @@ static void app_init(void) gdk_threads_set_lock_functions(thread_enter_func, thread_leave_func); gdk_threads_init(); + main_thread = g_thread_self(); } #endif syl_init(); diff --git a/src/query_search.c b/src/query_search.c index ff6a31ef..5261b49e 100644 --- a/src/query_search.c +++ b/src/query_search.c @@ -571,6 +571,7 @@ typedef struct _QueryData gint total; gint flag; GTimeVal tv_prev; + GSList *mlist; #if USE_THREADS GAsyncQueue *queue; guint timer_tag; @@ -622,8 +623,7 @@ static gpointer query_search_folder_func(gpointer data) g_async_queue_ref(qdata->queue); #endif - mlist = folder_item_get_msg_list(qdata->item, TRUE); - qdata->total = g_slist_length(mlist); + mlist = qdata->mlist; memset(&fltinfo, 0, sizeof(FilterInfo)); @@ -680,7 +680,6 @@ static gpointer query_search_folder_func(gpointer data) procheader_header_list_destroy(hlist); } - procmsg_msg_list_free(mlist); #if USE_THREADS g_async_queue_unref(qdata->queue); #endif @@ -724,6 +723,9 @@ static void query_search_folder(FolderItem *item) procmsg_set_auto_decrypt_message(FALSE); + data.mlist = folder_item_get_msg_list(item, TRUE); + data.total = g_slist_length(data.mlist); + #if USE_THREADS data.queue = g_async_queue_new(); data.timer_tag = g_timeout_add(PROGRESS_UPDATE_INTERVAL, @@ -733,6 +735,7 @@ static void query_search_folder(FolderItem *item) debug_print("query_search_folder: thread started\n"); while (g_atomic_int_get(&data.flag) == 0) gtk_main_iteration(); + log_window_flush(); while ((msginfo = g_async_queue_try_pop(data.queue))) query_search_append_msg(msginfo); @@ -746,6 +749,7 @@ static void query_search_folder(FolderItem *item) query_search_folder_func(&data); #endif + procmsg_msg_list_free(data.mlist); procmsg_set_auto_decrypt_message(TRUE); g_free(data.folder_name); } |