changeset 25068:53440f9bffba stable

disallow --gui option without GUI features (bug #53529) * main.in.cc (main): Exit early with error if --gui and --no-gui-libs are both used, or if --gui is used when Octave is not compiled with GUI libraries.
author John W. Eaton <jwe@octave.org>
date Sat, 31 Mar 2018 13:13:10 -0400
parents b940e457e11f
children 22bc3bcabba4
files src/main.in.cc
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.in.cc	Fri Mar 30 17:45:09 2018 -0400
+++ b/src/main.in.cc	Sat Mar 31 13:13:10 2018 -0400
@@ -243,7 +243,6 @@
           // require less memory.  Don't pass the --no-gui-libs option
           // on as that option is not recognized by Octave.
 
-          start_gui = false;
           gui_libs = false;
           file = octave_cli;
         }
@@ -303,6 +302,25 @@
         new_argv[k++] = argv[i];
     }
 
+  // At this point, gui_libs and start_gui are just about options, not
+  // the environment.  Exit if they don't make sense.
+
+  if (start_gui)
+    {
+      if (! gui_libs)
+        {
+          std::cerr << "octave: conflicting options: --no-gui-libs and --gui"
+                    << std::endl;
+          return 1;
+        }
+
+#if ! defined (HAVE_OCTAVE_QT_GUI)
+      std::cerr << "octave: GUI features missing or disabled in this build"
+                << std::endl;
+      return 1;
+#endif
+    }
+
   new_argv[k] = nullptr;
 
   if (no_display)