Prechádzať zdrojové kódy

startExecutable(): Use QProcess::start() instead of QProcess::startDetached() to fix the missing prompt after quitting vcmiclient or vcmieditor

vcmilauncher is now hidden while the child process is running, since it doesn't get repainted.

Fixes #2574
Alexander Wilms 1 rok pred
rodič
commit
875a8cc11a
2 zmenil súbory, kde vykonal 9 pridanie a 13 odobranie
  1. 7 13
      launcher/main.cpp
  2. 2 0
      launcher/mainwindow_moc.cpp

+ 7 - 13
launcher/main.cpp

@@ -108,19 +108,13 @@ void startEditor(const QStringList & args)
 #ifndef VCMI_MOBILE
 void startExecutable(QString name, const QStringList & args)
 {
+	// Start vcmiclient and vcmieditor with QProcess::start() instead of QProcess::startDetached()
+	// since startDetached() results in a missing terminal prompt after quitting vcmiclient.
+	// QProcess::start() causes the launcher window to freeze while the child process is running, so we hide it in
+	// MainWindow::on_startGameButton_clicked() and MainWindow::on_startEditorButton_clicked()
 	QProcess process;
-	
-	// Start the executable
-	if(process.startDetached(name, args))
-	{
-		qApp->quit();
-	}
-	else
-	{
-		QMessageBox::critical(qApp->activeWindow(),
-			QObject::tr("Error starting executable"),
-			QObject::tr("Failed to start %1\nReason: %2").arg(name, process.errorString())
-		);
-	}
+	process.start(name, args);
+	process.waitForFinished(-1);
+	qApp->quit();
 }
 #endif

+ 2 - 0
launcher/mainwindow_moc.cpp

@@ -196,11 +196,13 @@ MainWindow::~MainWindow()
 
 void MainWindow::on_startGameButton_clicked()
 {
+	hide();
 	startGame({});
 }
 
 void MainWindow::on_startEditorButton_clicked()
 {
+	hide();
 	startEditor({});
 }