~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/errors.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
18
18
 
19
19
#include "config.h"
20
20
 
 
21
#define _GNU_SOURCE  /* need the POSIX signal API */
 
22
 
21
23
#include <signal.h>
22
24
#include <stdarg.h>
23
25
#include <stdlib.h>
43
45
 
44
46
/*  private variables  */
45
47
 
 
48
static Gimp                *the_errors_gimp   = NULL;
46
49
static gboolean             use_debug_handler = FALSE;
47
50
static GimpStackTraceMode   stack_trace_mode  = GIMP_STACK_TRACE_QUERY;
48
51
static gchar               *full_prog_name    = NULL;
54
57
                                       const gchar *message,
55
58
                                       gboolean     use_handler);
56
59
 
 
60
static void   gimp_message_log_func (const gchar        *log_domain,
 
61
                                     GLogLevelFlags      flags,
 
62
                                     const gchar        *message,
 
63
                                     gpointer            data);
 
64
static void   gimp_error_log_func   (const gchar        *domain,
 
65
                                     GLogLevelFlags      flags,
 
66
                                     const gchar        *message,
 
67
                                     gpointer            data) G_GNUC_NORETURN;
 
68
 
 
69
 
57
70
 
58
71
/*  public functions  */
59
72
 
60
73
void
61
 
gimp_errors_init (const gchar        *_full_prog_name,
62
 
                  gboolean            _use_debug_handler,
63
 
                  GimpStackTraceMode  _stack_trace_mode)
 
74
errors_init (Gimp               *gimp,
 
75
             const gchar        *_full_prog_name,
 
76
             gboolean            _use_debug_handler,
 
77
             GimpStackTraceMode  _stack_trace_mode)
64
78
{
 
79
  const gchar * const log_domains[] =
 
80
  {
 
81
    "Gimp",
 
82
    "Gimp-Actions",
 
83
    "Gimp-Base",
 
84
    "Gimp-Composite",
 
85
    "Gimp-Config",
 
86
    "Gimp-Core",
 
87
    "Gimp-Dialogs",
 
88
    "Gimp-Display",
 
89
    "Gimp-File",
 
90
    "Gimp-GUI",
 
91
    "Gimp-Menus",
 
92
    "Gimp-PDB",
 
93
    "Gimp-Paint",
 
94
    "Gimp-Paint-Funcs",
 
95
    "Gimp-Plug-In",
 
96
    "Gimp-Text",
 
97
    "Gimp-Tools",
 
98
    "Gimp-Vectors",
 
99
    "Gimp-Widgets",
 
100
    "Gimp-XCF"
 
101
  };
 
102
  gint i;
 
103
 
 
104
  g_return_if_fail (GIMP_IS_GIMP (gimp));
65
105
  g_return_if_fail (_full_prog_name != NULL);
66
106
  g_return_if_fail (full_prog_name == NULL);
67
107
 
68
108
#ifdef GIMP_UNSTABLE
69
 
  g_printerr ("This is a development version of The GIMP.\n"
70
 
              "Debug messages may appear here.\n\n");
71
 
 
72
 
#ifdef G_OS_WIN32
73
 
  g_printerr ("You can minimize this window, but don't close it.\n\n");
74
 
#endif
 
109
  g_printerr ("This is a development version of GIMP.  "
 
110
              "Debug messages may appear here.\n\n");
75
111
#endif /* GIMP_UNSTABLE */
76
112
 
 
113
  the_errors_gimp   = gimp;
 
114
 
77
115
  use_debug_handler = _use_debug_handler ? TRUE : FALSE;
78
116
  stack_trace_mode  = _stack_trace_mode;
79
117
  full_prog_name    = g_strdup (_full_prog_name);
80
 
}
81
 
 
82
 
void
83
 
gimp_message_log_func (const gchar    *log_domain,
84
 
                       GLogLevelFlags  flags,
85
 
                       const gchar    *message,
86
 
                       gpointer        data)
87
 
{
88
 
  Gimp **gimp = (Gimp **) data;
89
 
 
90
 
  if (gimp && GIMP_IS_GIMP (*gimp))
91
 
    {
92
 
      gimp_message (*gimp, NULL, message);
93
 
      return;
94
 
    }
95
 
 
96
 
  g_printerr ("%s: %s\n\n", gimp_filename_to_utf8 (full_prog_name), message);
97
 
}
98
 
 
99
 
void
100
 
gimp_error_log_func (const gchar    *domain,
101
 
                     GLogLevelFlags  flags,
102
 
                     const gchar    *message,
103
 
                     gpointer        data)
104
 
{
105
 
  gimp_fatal_error (message);
 
118
 
 
119
  for (i = 0; i < G_N_ELEMENTS (log_domains); i++)
 
120
    g_log_set_handler (log_domains[i],
 
121
                       G_LOG_LEVEL_MESSAGE,
 
122
                       gimp_message_log_func, gimp);
 
123
 
 
124
  g_log_set_handler (NULL,
 
125
                     G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
 
126
                     gimp_error_log_func, gimp);
106
127
}
107
128
 
108
129
void
135
156
/*  private functions  */
136
157
 
137
158
static void
 
159
gimp_message_log_func (const gchar    *log_domain,
 
160
                       GLogLevelFlags  flags,
 
161
                       const gchar    *message,
 
162
                       gpointer        data)
 
163
{
 
164
  Gimp *gimp = data;
 
165
 
 
166
  if (gimp)
 
167
    {
 
168
      gimp_show_message (gimp, NULL, GIMP_MESSAGE_WARNING, NULL, message);
 
169
    }
 
170
  else
 
171
    {
 
172
      g_printerr ("%s: %s\n\n",
 
173
                  gimp_filename_to_utf8 (full_prog_name), message);
 
174
    }
 
175
}
 
176
 
 
177
static void
 
178
gimp_error_log_func (const gchar    *domain,
 
179
                     GLogLevelFlags  flags,
 
180
                     const gchar    *message,
 
181
                     gpointer        data)
 
182
{
 
183
  gimp_fatal_error (message);
 
184
}
 
185
 
 
186
static void
138
187
gimp_eek (const gchar *reason,
139
188
          const gchar *message,
140
189
          gboolean     use_handler)
141
190
{
142
191
#ifndef G_OS_WIN32
143
 
 
144
192
  g_printerr ("%s: %s: %s\n", gimp_filename_to_utf8 (full_prog_name),
145
193
              reason, message);
146
194
 
147
195
  if (use_handler)
148
196
    {
149
197
      switch (stack_trace_mode)
150
 
        {
151
 
        case GIMP_STACK_TRACE_NEVER:
152
 
          break;
153
 
 
154
 
        case GIMP_STACK_TRACE_QUERY:
155
 
          {
156
 
            sigset_t sigset;
157
 
 
158
 
            sigemptyset (&sigset);
159
 
            sigprocmask (SIG_SETMASK, &sigset, NULL);
160
 
            g_on_error_query (full_prog_name);
161
 
          }
162
 
          break;
163
 
 
164
 
        case GIMP_STACK_TRACE_ALWAYS:
165
 
          {
166
 
            sigset_t sigset;
167
 
 
168
 
            sigemptyset (&sigset);
169
 
            sigprocmask (SIG_SETMASK, &sigset, NULL);
170
 
            g_on_error_stack_trace (full_prog_name);
171
 
          }
172
 
          break;
173
 
 
174
 
        default:
175
 
          break;
176
 
        }
 
198
        {
 
199
        case GIMP_STACK_TRACE_NEVER:
 
200
          break;
 
201
 
 
202
        case GIMP_STACK_TRACE_QUERY:
 
203
          {
 
204
            sigset_t sigset;
 
205
 
 
206
            sigemptyset (&sigset);
 
207
            sigprocmask (SIG_SETMASK, &sigset, NULL);
 
208
 
 
209
            if (the_errors_gimp)
 
210
              gimp_gui_ungrab (the_errors_gimp);
 
211
 
 
212
            g_on_error_query (full_prog_name);
 
213
          }
 
214
          break;
 
215
 
 
216
        case GIMP_STACK_TRACE_ALWAYS:
 
217
          {
 
218
            sigset_t sigset;
 
219
 
 
220
            sigemptyset (&sigset);
 
221
            sigprocmask (SIG_SETMASK, &sigset, NULL);
 
222
 
 
223
            g_on_error_stack_trace (full_prog_name);
 
224
          }
 
225
          break;
 
226
 
 
227
        default:
 
228
          break;
 
229
        }
177
230
    }
178
 
 
179
231
#else
180
232
 
181
233
  /* g_on_error_* don't do anything reasonable on Win32. */