diff libinterp/dldfcn/__init_fltk__.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 bcc88f8f071d
children 6113e0c6920b 8dbd55742112
line wrap: on
line diff
--- a/libinterp/dldfcn/__init_fltk__.cc	Thu Apr 03 19:50:14 2014 -0400
+++ b/libinterp/dldfcn/__init_fltk__.cc	Fri Apr 04 10:48:07 2014 -0400
@@ -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");
+
           show ();
+
+#if defined (HAVE_X_WINDOWS)
+          std::string show_gui_msgs
+            = octave_env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
+
+          // Installing our handler suppresses the messages.
+          if (show_gui_msgs.empty ())
+            XSetErrorHandler (xerror_handler);
+#endif
+
           if (fp.get_currentaxes ().ok ())
             show_canvas ();
           else