src/ExternalPrograms.cc

changeset 644
93dcd1a0e4bd
parent 642
751a8df42842
child 690
9e9c52ca955e
equal deleted inserted replaced
643:a79277000830 644:93dcd1a0e4bd
142 #ifndef _WIN32 142 #ifndef _WIN32
143 if (*g_extProgWine[prog]) 143 if (*g_extProgWine[prog])
144 wineblurb = "make sure Wine is installed and "; 144 wineblurb = "make sure Wine is installed and ";
145 #endif 145 #endif
146 146
147 return fmt ("Program failed to start, %1check your permissions", wineblurb); 147 return format ("Program failed to start, %1check your permissions", wineblurb);
148 } break; 148 } break;
149 149
150 case QProcess::Crashed: 150 case QProcess::Crashed:
151 return "Crashed."; 151 return "Crashed.";
152 152
156 156
157 case QProcess::UnknownError: 157 case QProcess::UnknownError:
158 return "Unknown error"; 158 return "Unknown error";
159 159
160 case QProcess::Timedout: 160 case QProcess::Timedout:
161 return fmt ("Timed out (30 seconds)"); 161 return format ("Timed out (30 seconds)");
162 } 162 }
163 163
164 return ""; 164 return "";
165 } 165 }
166 166
192 // Write the input file 192 // Write the input file
193 QFile f (fname); 193 QFile f (fname);
194 194
195 if (!f.open (QIODevice::WriteOnly | QIODevice::Text)) 195 if (!f.open (QIODevice::WriteOnly | QIODevice::Text))
196 { 196 {
197 critical (fmt ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString())); 197 critical (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString()));
198 return; 198 return;
199 } 199 }
200 200
201 writeObjects (objects, f); 201 writeObjects (objects, f);
202 f.close(); 202 f.close();
243 argv.insert (0, path); 243 argv.insert (0, path);
244 path = "wine"; 244 path = "wine";
245 } 245 }
246 #endif // _WIN32 246 #endif // _WIN32
247 247
248 log ("cmdline: %1 %2\n", path, argv.join (" ")); 248 print ("Running command: %1 %2\n", path, argv.join (" "));
249 249
250 if (!input.open()) 250 if (!input.open())
251 return false; 251 return false;
252 252
253 QProcess proc; 253 QProcess proc;
256 proc.setStandardInputFile (input.fileName()); 256 proc.setStandardInputFile (input.fileName());
257 proc.start (path, argv); 257 proc.start (path, argv);
258 258
259 if (!proc.waitForStarted()) 259 if (!proc.waitForStarted())
260 { 260 {
261 critical (fmt ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc))); 261 critical (format ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc)));
262 return false; 262 return false;
263 } 263 }
264 264
265 // Write an enter, the utility tools all expect one 265 // Write an enter, the utility tools all expect one
266 input.write ("\n"); 266 input.write ("\n");
273 if (proc.exitStatus() != QProcess::NormalExit) 273 if (proc.exitStatus() != QProcess::NormalExit)
274 err = processErrorString (prog, proc); 274 err = processErrorString (prog, proc);
275 275
276 // Check the return code 276 // Check the return code
277 if (proc.exitCode() != 0) 277 if (proc.exitCode() != 0)
278 err = fmt ("Program exited abnormally (return code %1).", proc.exitCode()); 278 err = format ("Program exited abnormally (return code %1).", proc.exitCode());
279 279
280 if (!err.isEmpty()) 280 if (!err.isEmpty())
281 { 281 {
282 critical (fmt ("%1 failed: %2\n", g_extProgNames[prog], err)); 282 critical (format ("%1 failed: %2\n", g_extProgNames[prog], err));
283 return false; 283 return false;
284 } 284 }
285 285
286 return true; 286 return true;
287 } 287 }
297 // Read the output file 297 // Read the output file
298 QFile f (fname); 298 QFile f (fname);
299 299
300 if (!f.open (QIODevice::ReadOnly)) 300 if (!f.open (QIODevice::ReadOnly))
301 { 301 {
302 critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname)); 302 critical (format ("Couldn't open temporary file %1 for reading.\n", fname));
303 return; 303 return;
304 } 304 }
305 305
306 LDObjectList objs = loadFileContents (&f, null); 306 LDObjectList objs = loadFileContents (&f, null);
307 307
573 573
574 QString argv = join ( 574 QString argv = join (
575 { 575 {
576 (ui.cb_oldsweep->isChecked() ? "-s" : ""), 576 (ui.cb_oldsweep->isChecked() ? "-s" : ""),
577 (ui.cb_reverse->isChecked() ? "-r" : ""), 577 (ui.cb_reverse->isChecked() ? "-r" : ""),
578 (ui.dsb_segsplit->value() != 0 ? fmt ("-l %1", ui.dsb_segsplit->value()) : ""), 578 (ui.dsb_segsplit->value() != 0 ? format ("-l %1", ui.dsb_segsplit->value()) : ""),
579 (ui.sb_bias->value() != 0 ? fmt ("-s %1", ui.sb_bias->value()) : ""), 579 (ui.sb_bias->value() != 0 ? format ("-s %1", ui.sb_bias->value()) : ""),
580 in1DATName, 580 in1DATName,
581 in2DATName, 581 in2DATName,
582 outDATName 582 outDATName
583 }); 583 });
584 584
670 670
671 int unmatched = ui.unmatched->currentIndex(); 671 int unmatched = ui.unmatched->currentIndex();
672 672
673 QString argv = join ( 673 QString argv = join (
674 { 674 {
675 fmt ("-p %1", ui.precision->value()), 675 format ("-p %1", ui.precision->value()),
676 fmt ("-af %1", ui.flatAngle->value()), 676 format ("-af %1", ui.flatAngle->value()),
677 fmt ("-ac %1", ui.condAngle->value()), 677 format ("-ac %1", ui.condAngle->value()),
678 fmt ("-ae %1", ui.edgeAngle->value()), 678 format ("-ae %1", ui.edgeAngle->value()),
679 ui.delLines->isChecked() ? "-de" : "", 679 ui.delLines->isChecked() ? "-de" : "",
680 ui.delCondLines->isChecked() ? "-dc" : "", 680 ui.delCondLines->isChecked() ? "-dc" : "",
681 ui.colored->isChecked() ? "-c" : "", 681 ui.colored->isChecked() ? "-c" : "",
682 ui.bfc->isChecked() ? "-b" : "", 682 ui.bfc->isChecked() ? "-b" : "",
683 ui.convex->isChecked() ? "-cx" : "", 683 ui.convex->isChecked() ? "-cx" : "",

mercurial