diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-09-29 07:49:30 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-09-29 07:49:30 +0000 |
commit | a75654a326dadebacc229762eb01f5e7c65b1ccc (patch) | |
tree | 384933406e40aa0eae55368420af4b1391a568fc /src/main.c | |
parent | 1ff05553158408570a7cd548fdcdf4ec7be07f5d (diff) |
made GDK locks reentrant, and made LogWindow thread-safe.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2259 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -580,11 +580,32 @@ static gint get_queued_message_num(void) } #if USE_THREADS +/* enables recursive locking with gdk_thread_enter / gdk_threads_leave */ +static GStaticRecMutex syl_mutex = G_STATIC_REC_MUTEX_INIT; + +static void thread_enter_func(void) +{ + g_static_rec_mutex_lock(&syl_mutex); +#if 0 + syl_mutex_lock_count++; + if (syl_mutex_lock_count > 1) + g_print("enter: syl_mutex_lock_count: %d\n", syl_mutex_lock_count); +#endif +} + +static void thread_leave_func(void) +{ +#if 0 + syl_mutex_lock_count--; + if (syl_mutex_lock_count > 0) + g_print("leave: syl_mutex_lock_count: %d\n", syl_mutex_lock_count); +#endif + g_static_rec_mutex_unlock(&syl_mutex); +} + static void event_loop_iteration_func(void) { - //g_print("event_loop_iteration_func start\n"); gtk_main_iteration(); - //g_print("event_loop_iteration_func end\n"); } #endif @@ -595,8 +616,11 @@ static void app_init(void) g_thread_init(NULL); if (!g_thread_supported()) g_error("g_thread is not supported by glib."); - else + else { + gdk_threads_set_lock_functions(thread_enter_func, + thread_leave_func); gdk_threads_init(); + } #endif syl_init(); |