From: Vladimir Nadvornik Date: Sat, 9 Apr 2011 14:38:46 +0000 (+0200) Subject: fixed using DEBUG_N from multiple threads X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=20fab72e9ed2b9ae20967d5126556252e40c4dcf fixed using DEBUG_N from multiple threads --- diff --git a/src/debug.c b/src/debug.c index 01118192..c5848de9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -17,7 +17,7 @@ #include - +GMutex *debug_mutex; /* * Logging functions */ diff --git a/src/debug.h b/src/debug.h index 71f14970..d5c14f24 100644 --- a/src/debug.h +++ b/src/debug.h @@ -17,6 +17,8 @@ #define DOMAIN_DEBUG "debug" #define DOMAIN_INFO "info" +extern GMutex *debug_mutex; + gint log_domain_printf(const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3); #define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__) @@ -37,9 +39,11 @@ void init_exec_time(void); gint debug_level = get_debug_level(); \ if (debug_level >= (n)) \ { \ + g_mutex_lock(debug_mutex); \ if (debug_level != 1) log_domain_printf(DOMAIN_DEBUG, "%s:%d: ", __FILE__, __LINE__); \ log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \ log_domain_printf(DOMAIN_DEBUG, "\n"); \ + g_mutex_unlock(debug_mutex); \ } \ } while (0) diff --git a/src/main.c b/src/main.c index 7cad734e..b74235da 100644 --- a/src/main.c +++ b/src/main.c @@ -740,6 +740,8 @@ gint main(gint argc, gchar *argv[]) g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); + debug_mutex = g_mutex_new(); + #endif /* init execution time counter (debug only) */