changeset 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 e04d9375cd5f
children f44dd0186692
files dist-files.mk src/stable-octave-1-xerror.patch
diffstat 2 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 \
--- /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 <jwe@octave.org>
+# 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)