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