- ext programs requiring wine now properly display an error prompt if wine is missing

Thu, 19 Dec 2013 02:30:36 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 19 Dec 2013 02:30:36 +0200
changeset 569
0d6fce0628fe
parent 568
2fb6c500ff9e
child 570
e29a2ab838df

- ext programs requiring wine now properly display an error prompt if wine is missing

changelog.txt file | annotate | diff | comparison | revisions
src/extprogs.cc file | annotate | diff | comparison | revisions
--- a/changelog.txt	Thu Dec 19 01:25:50 2013 +0200
+++ b/changelog.txt	Thu Dec 19 02:30:36 2013 +0200
@@ -10,6 +10,7 @@
 	the registry under Windows and into ~/.config/LDForge under Linux. Unfortunately this means settings get
 	lost during transition from version 0.2 and 0.3.
 - Added a new editing mode for drawing circles.
+- Fixed: File loading would skip every 300th line (don't ask me how this managed to happen).
 - Major corrections to the primitive generator:
 	- Fixed: "Hi-Res" was not prepended to the names of 48/ primitives.
 	- Fixed: Checking the Hi-Res option would not allow segment values over 16.
@@ -44,7 +45,8 @@
 	and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
 - The camera icons now draw real tooltips instead of emulated ones.
 - Color icon border now reflects the color's edge color.
-- Fixed: File loading would skip every 300th line.
+- [Linux] Fixed: If an external program is attempted to be launched requiring Wine but with Wine missing,
+	there was no error message and instead LDForge took this as no output from the program.
 - Fixed: LDForge would sometimes crash during startup over uninitialized data in the GL renderer.
 - Fixed: The message log was still written with black text with dark backgrounds.
 
--- a/src/extprogs.cc	Thu Dec 19 01:25:50 2013 +0200
+++ b/src/extprogs.cc	Thu Dec 19 02:30:36 2013 +0200
@@ -113,10 +113,18 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static str processErrorString (QProcess& proc)
+static str processErrorString (extprog prog, QProcess& proc)
 {	switch (proc.error())
 	{	case QProcess::FailedToStart:
-			return "Failed to start (check your permissions)";
+		{	str wineblurb;
+
+#ifndef _WIN32
+			if (g_extProgWine[prog])
+				wineblurb = "make sure Wine is installed and ";
+#endif
+
+			return fmt ("Program failed to start, %1check your permissions", wineblurb);
+		} break;
 
 		case QProcess::Crashed:
 			return "Crashed.";
@@ -177,6 +185,10 @@
 
 	writeObjects (objects, f);
 	f.close();
+
+#ifdef DEBUG
+	QFile::copy (fname, "debug_lastInput");
+#endif
 }
 
 // =============================================================================
@@ -229,6 +241,11 @@
 	proc.setStandardInputFile (inputname);
 	proc.start (path, argv);
 
+	if (!proc.waitForStarted())
+	{	critical (fmt ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc)));
+		return false;
+	}
+
 	// Write an enter, the utility tools all expect one
 	stdinfp.write ("\n");
 
@@ -238,13 +255,13 @@
 	str err = "";
 
 	if (proc.exitStatus() != QProcess::NormalExit)
-		err = processErrorString (proc);
+		err = processErrorString (prog, proc);
 
 	// Check the return code
 	if (proc.exitCode() != 0)
 		err = fmt ("Program exited abnormally (return code %1).",  proc.exitCode());
 
-	if (err.length() > 0)
+	if (!err.isEmpty())
 	{	critical (fmt ("%1 failed: %2\n", g_extProgNames[prog], err));
 		return false;
 	}
@@ -256,7 +273,7 @@
 // -----------------------------------------------------------------------------
 static void insertOutput (str fname, bool replace, QList<int> colorsToReplace)
 {
-#ifndef RELEASE
+#ifdef DEBUG
 	QFile::copy (fname, "./debug_lastOutput");
 #endif // RELEASE
 

mercurial