r397 - in trunk: . scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jan 11 23:58:17 EST 2008


Author: icculus
Date: 2008-01-11 23:58:16 -0500 (Fri, 11 Jan 2008)
New Revision: 397

Modified:
   trunk/gui_gtkplus2.c
   trunk/lua_glue.c
   trunk/mojosetup.c
   trunk/scripts/mojosetup_mainline.lua
Log:
Changed fatal() so it only puts up an error box if the message isn't NULL, and
 other cleanups to reduce the amount of chatter when the user hits cancel.


Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c	2008-01-12 02:42:21 UTC (rev 396)
+++ trunk/gui_gtkplus2.c	2008-01-12 04:58:16 UTC (rev 397)
@@ -521,7 +521,7 @@
     gtk_widget_show(finallabel);
     gtk_box_pack_start(GTK_BOX(widget), finallabel, FALSE, TRUE, 0);
     gtk_label_set_justify(GTK_LABEL(finallabel), GTK_JUSTIFY_LEFT);
-    gtk_label_set_line_wrap(GTK_LABEL(finallabel), FALSE);
+    gtk_label_set_line_wrap(GTK_LABEL(finallabel), TRUE);
 
     gtk_signal_connect(GTK_OBJECT(window), "delete-event",
                        GTK_SIGNAL_FUNC(signal_delete), NULL);

Modified: trunk/lua_glue.c
===================================================================
--- trunk/lua_glue.c	2008-01-12 02:42:21 UTC (rev 396)
+++ trunk/lua_glue.c	2008-01-12 04:58:16 UTC (rev 397)
@@ -507,8 +507,6 @@
 static int luahook_fatal(lua_State *L)
 {
     const char *errstr = lua_tostring(L, 1);
-    if (errstr == NULL)
-        errstr = _("Unknown error");
     return fatal(errstr);  // doesn't actually return.
 } // luahook_fatal
 

Modified: trunk/mojosetup.c
===================================================================
--- trunk/mojosetup.c	2008-01-12 02:42:21 UTC (rev 396)
+++ trunk/mojosetup.c	2008-01-12 04:58:16 UTC (rev 397)
@@ -449,39 +449,44 @@
 int fatal(const char *fmt, ...)
 {
     static boolean in_fatal = false;
-    int len = 128;
-    char *buf = NULL;
-    int rc = 0;
-    va_list ap;
 
     if (in_fatal)
         return panic("BUG: fatal() called more than once!");
 
     in_fatal = true;
 
-    buf = xmalloc(len);
-    va_start(ap, fmt);
-    rc = vsnprintf(buf, len, fmt, ap);
-    va_end(ap);
-    if (rc >= len)
+    // may not want to show a message, since we displayed one elsewhere, etc.
+    if (fmt != NULL)
     {
-        len = rc;
-        buf = xrealloc(buf, len);
+        va_list ap;
+        int rc = 0;
+        int len = 128;
+        char *buf = xmalloc(len);
+
         va_start(ap, fmt);
-        vsnprintf(buf, len, fmt, ap);
+        rc = vsnprintf(buf, len, fmt, ap);
         va_end(ap);
+        if (rc >= len)
+        {
+            len = rc;
+            buf = xrealloc(buf, len);
+            va_start(ap, fmt);
+            vsnprintf(buf, len, fmt, ap);
+            va_end(ap);
+        } // if
+
+        logError("FATAL: %s", buf);
+
+        if (GGui != NULL)
+            GGui->msgbox(_("Fatal error"), buf);
+
+        free(buf);
     } // if
 
-    logError("FATAL: %s", buf);
+    // Shouldn't call fatal() before app is initialized!
     if ( (GGui == NULL) || (!MojoLua_initialized()) )
-    {
-        logError("fatal() called before app is initialized! Panicking...");
-        panic(buf);   // Shouldn't call fatal() before app is initialized!
-    } // if
+        panic("fatal() called before app is initialized! Panicking...");
 
-    GGui->msgbox(_("Fatal error"), buf);
-    free(buf);
-
     MojoLua_callProcedure("revertinstall");
 
     deinitEverything();

Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua	2008-01-12 02:42:21 UTC (rev 396)
+++ trunk/scripts/mojosetup_mainline.lua	2008-01-12 04:58:16 UTC (rev 397)
@@ -92,7 +92,7 @@
 function MojoSetup.revertinstall()
     -- !!! FIXME: language.
     if MojoSetup.gui_started then
-        MojoSetup.gui.final(_("There were errors. We will now put things back how we found them and exit."));
+        MojoSetup.gui.final(_("Incomplete installation. We will revert any changes we made."));
     end
 
     MojoSetup.loginfo("Cleaning up half-finished installation...");
@@ -257,7 +257,7 @@
         -- !!! FIXME: formatting!
         if not keepgoing then
             MojoSetup.logerror("User cancelled install during file write.")
-            MojoSetup.fatal(_("User cancelled installation."))
+            MojoSetup.fatal()
         else
             MojoSetup.logerror("Failed to create file '" .. dest .. "'")
             MojoSetup.fatal(_("File creation failed!"))
@@ -1027,7 +1027,7 @@
                 i = i - 1
             end
         elseif rc == 0 then
-            MojoSetup.fatal(_("User cancelled installation."))
+            MojoSetup.fatal()
         else
             MojoSetup.fatal(_("BUG: stage returned wrong value."))
         end




More information about the mojosetup-commits mailing list