# HG changeset patch # User John W. Eaton # Date 1395159796 14400 # Node ID 9735384a34fb49e39190f6bb23174a550f43ed5e # Parent e04d9375cd5ffc947b8e1317d8e9b87315793649 X11 error patch for stable-octave diff -r e04d9375cd5f -r 9735384a34fb dist-files.mk --- a/dist-files.mk Mon Mar 10 17:17:32 2014 -0400 +++ b/dist-files.mk Tue Mar 18 12:23:16 2014 -0400 @@ -545,6 +545,7 @@ sqlite.mk \ stable-octave-1-docinstall.patch \ stable-octave-1-fixes.patch \ + stable-octave-1-xerror.patch \ stable-octave.mk \ suitesparse-1.patch \ suitesparse.mk \ diff -r e04d9375cd5f -r 9735384a34fb src/stable-octave-1-xerror.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/stable-octave-1-xerror.patch Tue Mar 18 12:23:16 2014 -0400 @@ -0,0 +1,74 @@ +# HG changeset patch +# User John W. Eaton +# Date 1395159558 14400 +# Tue Mar 18 12:19:18 2014 -0400 +# Branch stable +# Node ID 90dbbafb0502e80f5855239bc18eacdab5d85a29 +# Parent c08776badd3d7d59b8c918a09710dfc1f18add3d +prevent X11 errors from appearing in GUI command window + +* octave-gui.cc (fdstderr): New file scope variable. +(octave_start_gui): Dup stderr. +(message_handler): Use fdstderr for messages. + +diff --git a/libgui/src/octave-gui.cc b/libgui/src/octave-gui.cc +--- a/libgui/src/octave-gui.cc ++++ b/libgui/src/octave-gui.cc +@@ -85,28 +85,37 @@ + int m_result; + }; + ++#if ! defined (__WIN32__) || defined (__CYGWIN__) ++static int fdstderr = -1; ++#endif + + // Custom message handler for filtering some messages from Qt. + +-void message_handler (QtMsgType type, const char *msg) ++void ++message_handler (QtMsgType type, const char *msg) + { ++#if ! defined (__WIN32__) || defined (__CYGWIN__) ++ static FILE *errstream = fdopen (fdstderr, "a+"); ++#else ++ static FILE *errstream = stderr; ++#endif ++ + switch (type) + { + case QtDebugMsg: +- if (strncmp (msg, "QFileSystemWatcher: skipping native engine",42) != 0) +- std::cerr << "Debug: " << msg << std::endl; ++ gnulib::fprintf (errstream, "Debug: %s\n", msg); + break; + + case QtWarningMsg: +- std::cerr << "Warning: " << msg << std::endl; ++ gnulib::fprintf (errstream, "Warning: %s\n", msg); + break; + + case QtCriticalMsg: +- std::cerr << "Critical: " << msg << std::endl; ++ gnulib::fprintf (errstream, "Critical: %s\n", msg); + break; + + case QtFatalMsg: +- std::cerr << "Fatal: " << msg << std::endl; ++ gnulib::fprintf (errstream, "Fatal: %s\n", msg); + abort (); + + default: +@@ -122,6 +131,13 @@ + { + octave_thread_manager::block_interrupt_signal (); + ++#if ! defined (__WIN32__) || defined (__CYGWIN__) ++ // Store the file descriptor associated with the STDERR stream. Send ++ // Qt messages there instead of to the STDERR stream that will be ++ // associated with the GUI command window. ++ fdstderr = gnulib::dup (STDERR_FILENO); ++#endif ++ + qInstallMsgHandler (message_handler); + + if (start_gui)