changeset 15161:973296940c89 gui

don't start GUI if display is not available * display.cc (display_info::dpy_avail): New data member. (display_info::display_info): Initialize dpy_avail. (display_info::init): Set dpy_avail. (display_info::display_available, display_info::do_display_available): New functions.
author John W. Eaton <jwe@octave.org>
date Sat, 11 Aug 2012 18:15:29 -0400
parents 098546e95a5e
children ad9523348676
files src/interp-core/display.cc src/interp-core/display.h src/octave.cc
diffstat 3 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/interp-core/display.cc
+++ b/src/interp-core/display.cc
@@ -79,6 +79,8 @@
 
           rx = wd * 25.4 / wd_mm;
           ry = ht * 25.4 / ht_mm;
+
+          dpy_avail = true;
         }
       else
         warning ("no graphical display found");
@@ -109,6 +111,8 @@
 
           rx = wd * 25.4 / wd_mm;
           ry = ht * 25.4 / ht_mm;
+
+          dpy_avail = true;
         }
       else
         warning ("no graphical display found");
@@ -144,6 +148,8 @@
                 warning ("X11 display has no default screen");
 
               XCloseDisplay (display);
+
+              dpy_avail = true;
             }
           else
             warning ("unable to open X11 DISPLAY");
--- a/src/interp-core/display.h
+++ b/src/interp-core/display.h
@@ -30,7 +30,7 @@
 protected:
 
   display_info (bool query = true)
-    : ht (1), wd (1), dp (0), rx (72), ry (72)
+    : ht (1), wd (1), dp (0), rx (72), ry (72), dpy_avail (false)
   {
     init (query);
   }
@@ -62,6 +62,11 @@
     return instance_ok () ? instance->do_y_dpi () : 0;
   }
 
+  static bool display_available (void)
+  {
+    return instance_ok () ? instance->do_display_available () : false;
+  }
+
   // To disable querying the window system for defaults, this function
   // must be called before any other display_info function.
   static void no_window_system (void)
@@ -84,6 +89,8 @@
   double rx;
   double ry;
 
+  bool dpy_avail;
+
   int do_height (void) const { return ht; }
   int do_width (void) const { return wd; }
   int do_depth (void) const { return dp; }
@@ -91,6 +98,8 @@
   double do_x_dpi (void) const { return rx; }
   double do_y_dpi (void) const { return ry; }
 
+  bool do_display_available (void) const { return dpy_avail; }
+
   void init (bool query = true);
 
   static bool instance_ok (bool query = true);
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -1020,6 +1020,9 @@
 int
 octave_starting_gui (void)
 {
+  if (! display_info::display_available ())
+    return false;
+
   if (force_gui_option)
     return true;