# HG changeset patch # User John W. Eaton # Date 1344723329 14400 # Node ID 973296940c8948e52f93c355b7ed4bdcffa24649 # Parent 098546e95a5e1b6cb8a3c2a5d878cab87a30da50 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. diff -r 098546e95a5e -r 973296940c89 src/interp-core/display.cc --- a/src/interp-core/display.cc Sat Aug 11 17:58:12 2012 -0400 +++ b/src/interp-core/display.cc Sat Aug 11 18:15:29 2012 -0400 @@ -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"); diff -r 098546e95a5e -r 973296940c89 src/interp-core/display.h --- a/src/interp-core/display.h Sat Aug 11 17:58:12 2012 -0400 +++ b/src/interp-core/display.h Sat Aug 11 18:15:29 2012 -0400 @@ -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); diff -r 098546e95a5e -r 973296940c89 src/octave.cc --- a/src/octave.cc Sat Aug 11 17:58:12 2012 -0400 +++ b/src/octave.cc Sat Aug 11 18:15:29 2012 -0400 @@ -1020,6 +1020,9 @@ int octave_starting_gui (void) { + if (! display_info::display_available ()) + return false; + if (force_gui_option) return true;