From 4a48f1cf6caab40fa3741d93f8c825078e4820f2 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 04 May 2007 21:15:31 +0000
Subject: [PATCH] Fix a number of issues with David's approval:

---
 opends/src/quicksetup/org/opends/quicksetup/Launcher.java |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
index a98b705..785847d 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -169,27 +169,25 @@
         }
         catch (Throwable t)
         {
-          try {
-            QuickSetupLog.initLogFileHandler(File.createTempFile(
-                "opends-launcher-", ".log"));
+          if (QuickSetupLog.isInitialized())
+          {
             LOG.log(Level.WARNING, "Error launching GUI: "+t);
+            StringBuilder buf = new StringBuilder();
             while (t != null)
             {
               StackTraceElement[] stack = t.getStackTrace();
               for (int i = 0; i < stack.length; i++)
               {
-                LOG.log(Level.WARNING, stack[i].toString());
+                buf.append(stack[i].toString()+"\n");
               }
 
               t = t.getCause();
               if (t != null)
               {
-                LOG.log(Level.WARNING, "Root cause:");
+                buf.append("Root cause:\n");
               }
             }
-          } catch (Throwable t2) {
-            System.err.println("Unable to initialize log");
-            t2.printStackTrace();
+            LOG.log(Level.WARNING, buf.toString());
           }
         }
       }
@@ -199,7 +197,7 @@
      * problems with the display environment.
      */
     PrintStream printStream = System.err;
-    //System.setErr(new EmptyPrintStream());
+    System.setErr(new EmptyPrintStream());
     t.start();
     try
     {
@@ -269,8 +267,10 @@
    * Called if launching of the GUI failed.  Here
    * subclasses can so application specific things
    * like print a message.
+   * @param logFileName the log file containing more information about why
+   * the launch failed.
    */
-  protected abstract void guiLaunchFailed();
+  protected abstract void guiLaunchFailed(String logFileName);
 
   /**
    * The main method which is called by the uninstall command lines.
@@ -286,7 +286,15 @@
       willLaunchGui();
       int exitCode = launchGui(args);
       if (exitCode != 0) {
-        guiLaunchFailed();
+        File logFile = QuickSetupLog.getLogFile();
+        if (logFile != null)
+        {
+          guiLaunchFailed(logFile.toString());
+        }
+        else
+        {
+          guiLaunchFailed(null);
+        }
         exitCode = launchCli(args, createCliApplication());
         if (exitCode != 0) {
           preExit();

--
Gitblit v1.10.0