Don't crash if there are command-line arguments (bug 261734) by doing ParseConfig before ParseArgs, moving gtk_init to RunWizard, and adding a check in ErrorHandler to log errors to the console if gtk hasn't been initialized yet. r=ajschultz, sr=dveditz.

This commit is contained in:
bryner%brianryner.com 2004-09-30 17:31:00 +00:00
parent c95ace691a
commit ea8b458e37
2 changed files with 10 additions and 9 deletions

View File

@ -156,7 +156,7 @@ BAIL:
}
int
nsXInstaller::RunWizard()
nsXInstaller::RunWizard(int argc, char **argv)
{
int err = OK;
@ -164,6 +164,7 @@ nsXInstaller::RunWizard()
// create the dialog window
if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) {
gtk_init(&argc, &argv);
gCtx->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
XI_VERIFY(gCtx->window);
@ -407,15 +408,13 @@ main(int argc, char **argv)
goto out;
}
if ((err = installer->ParseArgs(argc, argv)) != OK)
goto out;
gtk_init(&argc, &argv);
if ((err = installer->ParseConfig()) != OK)
goto out;
err = installer->RunWizard();
if ((err = installer->ParseArgs(argc, argv)) != OK)
goto out;
err = installer->RunWizard(argc, argv);
out:
XI_IF_DELETE(installer);
@ -447,7 +446,9 @@ ErrorHandler(int aErr, const char* aErrMsg)
sprintf(msg, gCtx->Res("FATAL_ERROR"), aErr, gCtx->Res(errStr));
}
if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) {
// lack of gCtx->window indicates we have not yet run RunWizard
// and gtk_init
if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT || !gCtx->window) {
fprintf (stderr, "%s\n", msg);
return aErr;
}

View File

@ -42,7 +42,7 @@ public:
int ParseArgs(int aArgc, char **aArgv);
int ParseConfig();
int RunWizard();
int RunWizard(int argc, char **argv);
int ParseGeneral(nsINIParser *aParser);
static gint Kill(GtkWidget *widget, GdkEvent *event, gpointer data);