[gimp] libgimp: add a gimp_fatal_func() allowing stack tracing plug-ins on...
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: add a gimp_fatal_func() allowing stack tracing plug-ins on...
- Date: Wed, 4 Apr 2018 02:35:50 +0000 (UTC)
commit e98b937643b005b9698ee042dc2250a5247fac23
Author: Jehan <jehan girinstud io>
Date: Wed Apr 4 04:33:19 2018 +0200
libgimp: add a gimp_fatal_func() allowing stack tracing plug-ins on...
... various crashes.
libgimp/gimp.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 789bd70..ac2b455 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -154,6 +154,10 @@ static void gimp_message_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer data);
+static void gimp_fatal_func (const gchar *log_domain,
+ GLogLevelFlags flags,
+ const gchar *message,
+ gpointer data);
#ifndef G_OS_WIN32
static void gimp_plugin_sigfatal_handler (gint sig_num);
#endif
@@ -589,6 +593,17 @@ gimp_main (const GimpPlugInInfo *info,
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
+
+ g_log_set_handler (NULL,
+ G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
+ gimp_fatal_func, NULL);
+ }
+ else
+ {
+ g_log_set_handler (NULL,
+ G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
+ gimp_fatal_func, NULL);
}
if (strcmp (argv[ARG_MODE], "-query") == 0)
@@ -1900,6 +1915,62 @@ gimp_message_func (const gchar *log_domain,
gimp_message (message);
}
+static void
+gimp_fatal_func (const gchar *log_domain,
+ GLogLevelFlags flags,
+ const gchar *message,
+ gpointer data)
+{
+ const gchar *level;
+
+ switch (flags & G_LOG_LEVEL_MASK)
+ {
+ case G_LOG_LEVEL_WARNING:
+ level = "WARNING";
+ break;
+ case G_LOG_LEVEL_CRITICAL:
+ level = "CRITICAL";
+ break;
+ case G_LOG_LEVEL_ERROR:
+ level = "ERROR";
+ break;
+ default:
+ level = "FATAL";
+ break;
+ }
+
+ g_printerr ("%s: %s: %s\n",
+ progname, level, message);
+
+ switch (stack_trace_mode)
+ {
+ case GIMP_STACK_TRACE_NEVER:
+ break;
+
+ case GIMP_STACK_TRACE_QUERY:
+ {
+ sigset_t sigset;
+
+ sigemptyset (&sigset);
+ sigprocmask (SIG_SETMASK, &sigset, NULL);
+ gimp_stack_trace_query (progname);
+ }
+ break;
+
+ case GIMP_STACK_TRACE_ALWAYS:
+ {
+ sigset_t sigset;
+
+ sigemptyset (&sigset);
+ sigprocmask (SIG_SETMASK, &sigset, NULL);
+ gimp_stack_trace_print (progname, stdout, NULL);
+ }
+ break;
+ }
+
+ gimp_quit ();
+}
+
#ifndef G_OS_WIN32
static void
gimp_plugin_sigfatal_handler (gint sig_num)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]