changeset 6781:2117b017e466

maint: Merge release to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 18 Jul 2023 18:28:52 +0200
parents 52802f7d049f (current diff) ecb84ac8b317 (diff)
children 057c321601eb
files binary-dist-rules.mk
diffstat 2 files changed, 27 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/binary-dist-rules.mk	Mon Jul 17 12:06:12 2023 -0400
+++ b/binary-dist-rules.mk	Tue Jul 18 18:28:52 2023 +0200
@@ -105,7 +105,7 @@
 
 ## FIXME: We aren't using VPATH?
 installer-files/octave-launch.exe: $(TOP_DIR)/installer-files/octave-launch.c installer-files/octave-launch.res | installer-files/.dirstamp
-	$(MXE_CC) $< -o $@ installer-files/octave-launch.res -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE $(OCTAVE_LAUNCH_NO_SHORT_CPPFLAGS)
+	$(MXE_CC) $< -o $@ installer-files/octave-launch.res -lshlwapi -municode -DUNICODE -D_UNICODE $(OCTAVE_LAUNCH_NO_SHORT_CPPFLAGS)
 
 .PHONY: octave-launch-firsttime
 octave-launch-firsttime: installer-files/octave-launch-firsttime.exe
--- a/installer-files/octave-launch.c	Mon Jul 17 12:06:12 2023 -0400
+++ b/installer-files/octave-launch.c	Tue Jul 18 18:28:52 2023 +0200
@@ -1,7 +1,7 @@
 /*
- * Wrapper application to set octave env variables and then run octave
+ * Windows wrapper application to set Octave env variables and then run Octave.
  *
- * Copyright (C) 2020-2021 John Donoghue <john.donoghue@ieee.org>
+ * Copyright (C) 2020-2023 John Donoghue <john.donoghue@ieee.org>
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -87,11 +87,11 @@
 {
   PROCESS_INFORMATION pi;
 
-  // FIXME: There are currently have no checks to ensure that the
-  // following fixed-size buffers are sufficiently large.  MAX_PATH is
-  // 260 on Winndows by default.  But a user might have increased that
-  // limit to 32767 characters by manually changing policy settings.
-  // Maybe it would be better if we used C++ and std::string objects?
+  // FIXME: There are currently no checks to ensure that the following
+  // fixed-size buffers are sufficiently large.  MAX_PATH is 260 on
+  // Windows by default.  But a user might have increased that limit to
+  // 32767 characters by manually changing policy settings.  Maybe it
+  // would be better if we used C++ and std::string objects?
   // Note that the use of sizeof(path)-1 will fail if we switch to
   // using
   //
@@ -125,7 +125,7 @@
 #else
   /* transform to short paths to work around issues with spaces in
      paths */
-  /* FIXME: This won't help on systems with de-activated short paths */
+  /* FIXME: This won't help on systems with de-activated short paths. */
   nSize = GetShortPathNameW (path, rootpath, PATH_SZ-1);
   if (nSize == 0)
     StringCchCopyW (rootpath, PATH_SZ, path);
@@ -177,7 +177,7 @@
         }
     }
 
-  /* binpath is to the octave bin dir so get the parent */
+  /* binpath is to the Octave bin dir so get the parent */
   StringCchCopyW (path, PATH_SZ, binpath);
   ParentDir (path);
 
@@ -352,13 +352,16 @@
     StringCchCopyW (argbuffer, ARGBUF_SZ, L"octave.exe ");
     StringCchCatW (path, PATH_SZ, L"\\octave.exe");
 
-    /* If parent process has a console, attach to it.
-       Let the function fail silently, when parent has no console
-       (e.g., when program has been started from link in start menu).
-       No console will be shown in this case. */
-    AttachConsole (ATTACH_PARENT_PROCESS);
-
-    if (! (no_gui_libs || no_gui_arg_found))
+    DWORD no_window = 0;
+    if (no_gui_libs || no_gui_arg_found)
+      {
+        /* If parent process has a console, attach to it.
+           Let the function fail silently, when parent has no console
+           (e.g., when program has been started from link in start menu).
+           No console will be shown in this case. */
+        AttachConsole (ATTACH_PARENT_PROCESS);
+      }
+    else
       {
         /* Unless --no-gui or --no-gui-libs is specified, we will use a GUI window.  */
         si.dwFlags = STARTF_USESHOWWINDOW;
@@ -369,6 +372,12 @@
 
         if (! gui_arg_found)
           StringCchCatW (argbuffer, ARGBUF_SZ, L"--gui ");
+
+        /* Detach from the console to allow hiding it. */
+        FreeConsole ();
+
+        /* Suppress creating a new console when starting the GUI. */
+        no_window = CREATE_NO_WINDOW;
       }
 
     /* quote and append each arg */
@@ -385,7 +394,7 @@
                                  NULL,      // Process handle not inheritable
                                  NULL,      // Thread handle not inheritable
                                  FALSE,     // Set handle inheritance to FALSE
-                                 0,         // No creation flags
+                                 no_window | CREATE_UNICODE_ENVIRONMENT,  // Creation flags
                                  NULL,      // Use parent's environment block
                                  NULL,      // Use parent's starting directory
                                  &si,       // Pointer to STARTUPINFO