changeset 3576:f46a7bbfc491

fix stable-octave-2-xerror.patch file
author John W. Eaton <jwe@octave.org>
date Thu, 10 Apr 2014 10:35:26 -0400
parents a247dc2d32c0
children 1ab2022ff6c7
files src/stable-octave-2-xerror.patch
diffstat 1 files changed, 123 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/stable-octave-2-xerror.patch	Tue Apr 08 22:00:46 2014 -0400
+++ b/src/stable-octave-2-xerror.patch	Thu Apr 10 10:35:26 2014 -0400
@@ -0,0 +1,123 @@
+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,42 +85,11 @@
+   int m_result;
+ };
+ 
+-#if ! defined (__WIN32__) || defined (__CYGWIN__)
+-static int fdstderr = -1;
+-#endif
++// Disable all Qt messages by default.
+ 
+-// Custom message handler for filtering some messages from Qt.
+-
+-void
++static 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:
+-      gnulib::fprintf (errstream, "Debug: %s\n", msg);
+-      break;
+-
+-    case QtWarningMsg:
+-      gnulib::fprintf (errstream, "Warning: %s\n", msg);
+-      break;
+-
+-    case QtCriticalMsg:
+-      gnulib::fprintf (errstream, "Critical: %s\n", msg);
+-      break;
+-
+-    case QtFatalMsg:
+-      gnulib::fprintf (errstream, "Fatal: %s\n", msg);
+-      abort ();
+-
+-    default:
+-      break;
+-    }
+ }
+ 
+ // If START_GUI is false, we still set up the QApplication so that we
+@@ -131,14 +100,11 @@
+ {
+   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
++  std::string show_gui_msgs = octave_env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
+ 
+-  qInstallMsgHandler (message_handler);
++  // Installing our handler suppresses the messages.
++  if (show_gui_msgs.empty ())
++    qInstallMsgHandler (message_handler);
+ 
+   if (start_gui)
+     {
+diff --git a/libinterp/dldfcn/__init_fltk__.cc b/libinterp/dldfcn/__init_fltk__.cc
+--- a/libinterp/dldfcn/__init_fltk__.cc
++++ b/libinterp/dldfcn/__init_fltk__.cc
+@@ -42,6 +42,10 @@
+ 
+ #ifdef HAVE_FLTK
+ 
++#if defined (HAVE_X_WINDOWS)
++#include <X11/Xlib.h>
++#endif
++
+ #include <map>
+ #include <set>
+ #include <sstream>
+@@ -73,6 +77,7 @@
+ 
+ #include "cmd-edit.h"
+ #include "lo-ieee.h"
++#include "oct-env.h"
+ 
+ #include "display.h"
+ #include "file-ops.h"
+@@ -674,6 +679,14 @@
+   Fl_Menu_Bar* menubar;
+ };
+ 
++#if defined (HAVE_X_WINDOWS)
++static int
++xerror_handler (Display *, XErrorEvent *)
++{
++  return 0;
++}
++#endif
++
+ class plot_window : public Fl_Window
+ {
+   friend class fltk_uimenu;
+@@ -762,7 +775,18 @@
+           // Set WM_CLASS which allows window managers to properly group
+           // related windows.  Otherwise, the class is just "FLTK"
+           xclass ("Octave");
++
++          std::string show_gui_msgs
++            = octave_env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
++
++#if defined (HAVE_X_WINDOWS)
++          // Installing our handler suppresses the messages.
++          if (show_gui_msgs.empty ())
++            XSetErrorHandler (xerror_handler);
++#endif
++
+           show ();
++
+           if (fp.get_currentaxes ().ok ())
+             show_canvas ();
+           else