Mercurial > octave-libgccjit
comparison libgui/src/octave-gui.cc @ 18618:c644cfa9cb3b stable
suppress all X11 and Qt error messages by default
* octave-gui.cc (fdstderr): Delete variable and all uses.
(message_handler): Don't print anything.
(octave_start_gui): Check OCTAVE_SHOW_GUI_MESSAGES environment
variable to decide whether to install message_handler to suppress
messages.
* __init_fltk__.cc (xerror_handler): New function.
(plot_window::plot_window): Check OCTAVE_SHOW_GUI_MESSAGES environment
variable to decide whether to install xerror_handler to suppress
messages.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 04 Apr 2014 10:48:07 -0400 |
parents | 90dbbafb0502 |
children | f1b91e3137b9 |
comparison
equal
deleted
inserted
replaced
18616:aa861a98d84d | 18618:c644cfa9cb3b |
---|---|
83 int m_argc; | 83 int m_argc; |
84 char** m_argv; | 84 char** m_argv; |
85 int m_result; | 85 int m_result; |
86 }; | 86 }; |
87 | 87 |
88 #if ! defined (__WIN32__) || defined (__CYGWIN__) | 88 // Disable all Qt messages by default. |
89 static int fdstderr = -1; | |
90 #endif | |
91 | 89 |
92 // Custom message handler for filtering some messages from Qt. | 90 static void |
93 | |
94 void | |
95 message_handler (QtMsgType type, const char *msg) | 91 message_handler (QtMsgType type, const char *msg) |
96 { | 92 { |
97 #if ! defined (__WIN32__) || defined (__CYGWIN__) | |
98 static FILE *errstream = fdopen (fdstderr, "a+"); | |
99 #else | |
100 static FILE *errstream = stderr; | |
101 #endif | |
102 | |
103 switch (type) | |
104 { | |
105 case QtDebugMsg: | |
106 gnulib::fprintf (errstream, "Debug: %s\n", msg); | |
107 break; | |
108 | |
109 case QtWarningMsg: | |
110 gnulib::fprintf (errstream, "Warning: %s\n", msg); | |
111 break; | |
112 | |
113 case QtCriticalMsg: | |
114 gnulib::fprintf (errstream, "Critical: %s\n", msg); | |
115 break; | |
116 | |
117 case QtFatalMsg: | |
118 gnulib::fprintf (errstream, "Fatal: %s\n", msg); | |
119 abort (); | |
120 | |
121 default: | |
122 break; | |
123 } | |
124 } | 93 } |
125 | 94 |
126 // If START_GUI is false, we still set up the QApplication so that we | 95 // If START_GUI is false, we still set up the QApplication so that we |
127 // can use Qt widgets for plot windows. | 96 // can use Qt widgets for plot windows. |
128 | 97 |
129 int | 98 int |
130 octave_start_gui (int argc, char *argv[], bool start_gui) | 99 octave_start_gui (int argc, char *argv[], bool start_gui) |
131 { | 100 { |
132 octave_thread_manager::block_interrupt_signal (); | 101 octave_thread_manager::block_interrupt_signal (); |
133 | 102 |
134 #if ! defined (__WIN32__) || defined (__CYGWIN__) | 103 std::string show_gui_msgs = octave_env::getenv ("OCTAVE_SHOW_GUI_MESSAGES"); |
135 // Store the file descriptor associated with the STDERR stream. Send | |
136 // Qt messages there instead of to the STDERR stream that will be | |
137 // associated with the GUI command window. | |
138 fdstderr = gnulib::dup (STDERR_FILENO); | |
139 #endif | |
140 | 104 |
141 qInstallMsgHandler (message_handler); | 105 // Installing our handler suppresses the messages. |
106 if (show_gui_msgs.empty ()) | |
107 qInstallMsgHandler (message_handler); | |
142 | 108 |
143 if (start_gui) | 109 if (start_gui) |
144 { | 110 { |
145 QApplication application (argc, argv); | 111 QApplication application (argc, argv); |
146 QTranslator gui_tr, qt_tr, qsci_tr; | 112 QTranslator gui_tr, qt_tr, qsci_tr; |