From: Richard Heck [rgh...@comcast.net]
Sent: Sunday, May 20, 2012 9:53 AM

>I think the GUI is accessible at this point---if use_gui is true. So you might 
>just try something like:
>    if (use_gui)
>        frontend::Alert(...);
>    else
>        LYXERR0(...);
>at the relevant point. If not, then we need more complex return values from 
>init().

The attached patch issues a GUI message if configure fails. I wasn't sure about 
where to put the code. It is unfortunately spread out because I couldn't issue 
a GUI message at the time of checking if configure succeeded.

The patch also includes two minor changes to the reconfigure code in 
GuiApplication::reconfigure:

(1) I "consted" the return value and (2) I added a line break to the message.

Scott
diff --git a/src/LyX.cpp b/src/LyX.cpp
index 6b46066..29e64bb 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -104,6 +104,11 @@ RunMode run_mode = PREFERRED;
 OverwriteFiles force_overwrite = UNSPECIFIED;
 
 
+// We will check whether configure.py failed.
+
+int configure_failed;
+
+
 namespace {
 
 // Filled with the command line arguments "foo" of "-sysdir foo" or
@@ -130,8 +135,11 @@ void reconfigureUserLyXDir()
 	lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
 	PathChanger p(package().user_support());
 	Systemcall one;
-	one.startscript(Systemcall::Wait, configure_command);
-	lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
+	configure_failed = one.startscript(Systemcall::Wait, configure_command);
+	if (configure_failed) // We also issue a GUI notification later on.
+		lyxerr << "Error: reconfiguration failed" << endl;
+	else
+		lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
 }
 
 } // namespace anon
@@ -581,6 +589,15 @@ void LyX::execCommands()
 	} else
 		pimpl_->application_->restoreGuiSession();
 
+	if (configure_failed) {
+                Alert::information(_("System configuration failed"),
+                           _("The system configuration has failed.\n"
+                                  "Default textclass is used but LyX may\n"
+                                  "not be able to work properly.\n"
+                                  "Please reconfigure again if needed\n"
+                                  "by going to Tools > Reconfigure."));
+	}
+
 	// Execute batch commands if available
 	if (pimpl_->batch_commands.empty())
 		return;
diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp
index 2cec2e3..8e96ed0 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1252,7 +1252,7 @@ void GuiApplication::reconfigure(string const & option)
 	string configure_command = package().configure_command();
 	configure_command += option;
 	Systemcall one;
-	int ret = one.startscript(Systemcall::Wait, configure_command);
+	const int ret = one.startscript(Systemcall::Wait, configure_command);
 	p.pop();
 	// emit message signal.
 	if (current_view_)
@@ -1264,7 +1264,7 @@ void GuiApplication::reconfigure(string const & option)
 	if (ret)
 		Alert::information(_("System reconfiguration failed"),
 			   _("The system reconfiguration has failed.\n"
-				  "Default textclass is used but LyX may "
+				  "Default textclass is used but LyX may\n"
 				  "not be able to work properly.\n"
 				  "Please reconfigure again if needed."));
 	else

Reply via email to