From 8196fb4b69d9d0da97286942f27a9f8448bae97d Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Thu, 31 Jul 2008 20:01:49 +0200
Subject: [PATCH] Disabled the windows dll load error dialogs by default and
 added an option -rl to enable them.

Rev: src/configure.in:1.1067
Rev: src/main.c:1.232
Rev: src/pike_embed.h:1.11
---
 src/configure.in |  9 +++++----
 src/main.c       | 26 +++++++++++++++++++++++++-
 src/pike_embed.h |  7 ++++---
 3 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/configure.in b/src/configure.in
index 312dc3756d..0f464cd73e 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,4 @@
-AC_REVISION("$Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $")
+AC_REVISION("$Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $")
 AC_INIT(interpret.c)
 AC_CONFIG_HEADER(machine.h)
 
@@ -2392,7 +2392,7 @@ if test "x$PIKE_PATH_TRANSLATE" = "x"; then
     # MinGW system.
     cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # MinGW-version. Do NOT edit.
 posix_name="`cat`"
 posix_prefix="/"
@@ -2430,7 +2430,7 @@ EOF
     # Native POSIX system.
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # POSIX-version. Do NOT edit.
 cat
 EOF
@@ -2439,7 +2439,7 @@ else
   # rntcl-style
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # RNTCL-version. Do NOT edit.
 sed -e "$PIKE_PATH_TRANSLATE"
 EOF
@@ -4453,6 +4453,7 @@ AC_CHECK_FUNCS( \
  GetSystemInfo \
  clock_getcpuclockid \
  backtrace \
+ SetErrorMode \
 )
 
 # SunOS 4 realloc() returns NULL when reallocing NULL.
diff --git a/src/main.c b/src/main.c
index 41a37b550e..ef384f60fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: main.c,v 1.231 2008/06/29 10:40:55 mast Exp $
+|| $Id: main.c,v 1.232 2008/07/31 18:01:48 mast Exp $
 */
 
 #include "global.h"
@@ -468,6 +468,12 @@ int main(int argc, char **argv)
 	    p++;
 	    goto more_r_flags;
 
+	  case 'l':
+	    set_pike_runtime_options (RUNTIME_ERROR_DIALOGS,
+				      RUNTIME_ERROR_DIALOGS);
+	    p++;
+	    goto more_d_flags;
+
          default:
             p++;
 	    break;
@@ -539,6 +545,24 @@ int main(int argc, char **argv)
   if (d_flag)
     set_pike_debug_options(ERRORCHECK_MUTEXES, ERRORCHECK_MUTEXES);
 
+#ifdef HAVE_SETERRORMODE
+  if (!(runtime_options & RUNTIME_ERROR_DIALOGS)) {
+    /* This avoids popups when LoadLibrary fails to find a dll.
+     *
+     * Note that the popup is the _only_ way to see which dll (loaded
+     * indirectly by dependencies from the one in the LoadLibrary
+     * call) that Windows didn't find. :( Hence the -rl runtime option
+     * to turn it on.
+     *
+     * Note: This setting is process global. */
+    SetErrorMode (SEM_FAILCRITICALERRORS |
+		  /* Maybe set this too? Don't know exactly when it
+		   * has effect. /mast */
+		  /*SEM_NOOPENFILEERRORBOX | */
+		  GetErrorMode());
+  }
+#endif
+
   init_pike_runtime(exit);
 
   /* NOTE: Reuse master_location here to avoid duplicates of
diff --git a/src/pike_embed.h b/src/pike_embed.h
index 9c9aaeee4b..243a23f48f 100644
--- a/src/pike_embed.h
+++ b/src/pike_embed.h
@@ -1,5 +1,5 @@
 /*
- * $Id: pike_embed.h,v 1.10 2008/06/05 15:12:44 mast Exp $
+ * $Id: pike_embed.h,v 1.11 2008/07/31 18:01:49 mast Exp $
  *
  * Pike embedding API.
  *
@@ -33,8 +33,9 @@ extern int yydebug;
 int set_pike_debug_options(int bits, int mask);
 
 /* Runtime options */
-#define RUNTIME_CHECK_TYPES  1
-#define RUNTIME_STRICT_TYPES 2
+#define RUNTIME_CHECK_TYPES	1
+#define RUNTIME_STRICT_TYPES	2
+#define RUNTIME_ERROR_DIALOGS	4
 
 int set_pike_runtime_options(int bits, int mask);
 
-- 
GitLab