comparison src/stable-octave-1-xerror.patch @ 3567:9735384a34fb

X11 error patch for stable-octave
author John W. Eaton <jwe@octave.org>
date Tue, 18 Mar 2014 12:23:16 -0400
parents
children
comparison
equal deleted inserted replaced
3566:e04d9375cd5f 3567:9735384a34fb
1 # HG changeset patch
2 # User John W. Eaton <jwe@octave.org>
3 # Date 1395159558 14400
4 # Tue Mar 18 12:19:18 2014 -0400
5 # Branch stable
6 # Node ID 90dbbafb0502e80f5855239bc18eacdab5d85a29
7 # Parent c08776badd3d7d59b8c918a09710dfc1f18add3d
8 prevent X11 errors from appearing in GUI command window
9
10 * octave-gui.cc (fdstderr): New file scope variable.
11 (octave_start_gui): Dup stderr.
12 (message_handler): Use fdstderr for messages.
13
14 diff --git a/libgui/src/octave-gui.cc b/libgui/src/octave-gui.cc
15 --- a/libgui/src/octave-gui.cc
16 +++ b/libgui/src/octave-gui.cc
17 @@ -85,28 +85,37 @@
18 int m_result;
19 };
20
21 +#if ! defined (__WIN32__) || defined (__CYGWIN__)
22 +static int fdstderr = -1;
23 +#endif
24
25 // Custom message handler for filtering some messages from Qt.
26
27 -void message_handler (QtMsgType type, const char *msg)
28 +void
29 +message_handler (QtMsgType type, const char *msg)
30 {
31 +#if ! defined (__WIN32__) || defined (__CYGWIN__)
32 + static FILE *errstream = fdopen (fdstderr, "a+");
33 +#else
34 + static FILE *errstream = stderr;
35 +#endif
36 +
37 switch (type)
38 {
39 case QtDebugMsg:
40 - if (strncmp (msg, "QFileSystemWatcher: skipping native engine",42) != 0)
41 - std::cerr << "Debug: " << msg << std::endl;
42 + gnulib::fprintf (errstream, "Debug: %s\n", msg);
43 break;
44
45 case QtWarningMsg:
46 - std::cerr << "Warning: " << msg << std::endl;
47 + gnulib::fprintf (errstream, "Warning: %s\n", msg);
48 break;
49
50 case QtCriticalMsg:
51 - std::cerr << "Critical: " << msg << std::endl;
52 + gnulib::fprintf (errstream, "Critical: %s\n", msg);
53 break;
54
55 case QtFatalMsg:
56 - std::cerr << "Fatal: " << msg << std::endl;
57 + gnulib::fprintf (errstream, "Fatal: %s\n", msg);
58 abort ();
59
60 default:
61 @@ -122,6 +131,13 @@
62 {
63 octave_thread_manager::block_interrupt_signal ();
64
65 +#if ! defined (__WIN32__) || defined (__CYGWIN__)
66 + // Store the file descriptor associated with the STDERR stream. Send
67 + // Qt messages there instead of to the STDERR stream that will be
68 + // associated with the GUI command window.
69 + fdstderr = gnulib::dup (STDERR_FILENO);
70 +#endif
71 +
72 qInstallMsgHandler (message_handler);
73
74 if (start_gui)