Fix a few bugs in profilers.

* Legacy was launching before the profiler.
* Some clarity changes.
* Report problem with empty strings as profiler paths.
This commit is contained in:
Petr Mrázek 2014-02-16 00:10:45 +01:00
parent 8219dbf612
commit 7ceb2cacb1
6 changed files with 73 additions and 24 deletions

View File

@ -29,7 +29,8 @@ public class EntryPoint
private enum Action private enum Action
{ {
Proceed, Proceed,
Launch Launch,
Abort
} }
public static void main(String[] args) public static void main(String[] args)
@ -62,8 +63,17 @@ public class EntryPoint
{ {
String[] pair = inData.split(" ", 2); String[] pair = inData.split(" ", 2);
if(pair.length == 1 && pair[0].equals("launch")) if(pair.length == 1)
return Action.Launch; {
String command = pair[0];
if (pair[0].equals("launch"))
return Action.Launch;
else if (pair[0].equals("abort"))
return Action.Abort;
else throw new ParseException();
}
if(pair.length != 2) if(pair.length != 2)
throw new ParseException(); throw new ParseException();
@ -109,6 +119,7 @@ public class EntryPoint
return 1; return 1;
} }
boolean isListening = true; boolean isListening = true;
boolean isAborted = false;
// Main loop // Main loop
while (isListening) while (isListening)
{ {
@ -119,7 +130,13 @@ public class EntryPoint
inData = buffer.readLine(); inData = buffer.readLine();
if (inData != null) if (inData != null)
{ {
if(parseLine(inData) == Action.Launch) Action a = parseLine(inData);
if(a == Action.Abort)
{
isListening = false;
isAborted = true;
}
if(a == Action.Launch)
{ {
isListening = false; isListening = false;
} }
@ -138,6 +155,11 @@ public class EntryPoint
return 1; return 1;
} }
} }
if(isAborted)
{
System.err.println("Launch aborted by MultiMC.");
return 1;
}
if(m_launcher != null) if(m_launcher != null)
{ {
return m_launcher.launch(m_params); return m_launcher.launch(m_params);

View File

@ -1239,7 +1239,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session,
connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded()));
proc->setLogin(session); proc->setLogin(session);
proc->launch(); proc->arm();
if (profiler) if (profiler)
{ {
@ -1247,6 +1247,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session,
if (!profiler->check(&error)) if (!profiler->check(&error))
{ {
QMessageBox::critical(this, tr("Error"), tr("Couldn't start profiler: %1").arg(error)); QMessageBox::critical(this, tr("Error"), tr("Couldn't start profiler: %1").arg(error));
proc->abort();
return; return;
} }
BaseProfiler *profilerInstance = profiler->createProfiler(instance, this); BaseProfiler *profilerInstance = profiler->createProfiler(instance, this);
@ -1267,14 +1268,14 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session,
msg.setIcon(QMessageBox::Information); msg.setIcon(QMessageBox::Information);
msg.addButton(tr("Launch"), QMessageBox::AcceptRole); msg.addButton(tr("Launch"), QMessageBox::AcceptRole);
msg.exec(); msg.exec();
proc->write("launch\n"); proc->launch();
}); });
profilerInstance->beginProfiling(proc); profilerInstance->beginProfiling(proc);
dialog.exec(); dialog.exec();
} }
else else
{ {
proc->write("launch\n"); proc->launch();
} }
} }

View File

@ -528,14 +528,15 @@ void SettingsDialog::on_jprofilerPathBtn_clicked()
} }
void SettingsDialog::on_jprofilerCheckBtn_clicked() void SettingsDialog::on_jprofilerCheckBtn_clicked()
{ {
if (!ui->jprofilerPathEdit->text().isEmpty()) QString error;
if (!MMC->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error))
{ {
QString error; QMessageBox::critical(this, tr("Error"),
if (!MMC->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error)) tr("Error while checking JProfiler install:\n%1").arg(error));
{ }
QMessageBox::critical(this, tr("Error"), else
tr("Error while checking JProfiler install:\n%1").arg(error)); {
} QMessageBox::information(this, tr("OK"), tr("JProfiler setup seems to be OK"));
} }
} }
@ -553,13 +554,14 @@ void SettingsDialog::on_jvisualvmPathBtn_clicked()
} }
void SettingsDialog::on_jvisualvmCheckBtn_clicked() void SettingsDialog::on_jvisualvmCheckBtn_clicked()
{ {
if (!ui->jvisualvmPathEdit->text().isEmpty()) QString error;
if (!MMC->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error))
{ {
QString error; QMessageBox::critical(this, tr("Error"),
if (!MMC->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error)) tr("Error while checking JVisualVM install:\n%1").arg(error));
{ }
QMessageBox::critical(this, tr("Error"), else
tr("Error while checking JVisualVM install:\n%1").arg(error)); {
} QMessageBox::information(this, tr("OK"), tr("JVisualVM setup seems to be OK"));
} }
} }

View File

@ -77,7 +77,7 @@ MinecraftProcess *LegacyInstance::prepareForLaunch(AuthSessionPtr account)
launchScript += "windowTitle " + windowTitle() + "\n"; launchScript += "windowTitle " + windowTitle() + "\n";
launchScript += "windowParams " + windowParams + "\n"; launchScript += "windowParams " + windowParams + "\n";
launchScript += "lwjgl " + lwjgl + "\n"; launchScript += "lwjgl " + lwjgl + "\n";
launchScript += "launch legacy\n"; launchScript += "launcher legacy\n";
} }
proc->setLaunchScript(launchScript); proc->setLaunchScript(launchScript);

View File

@ -288,7 +288,7 @@ void MinecraftProcess::killMinecraft()
kill(); kill();
} }
void MinecraftProcess::launch() void MinecraftProcess::arm()
{ {
emit log("MultiMC version: " + MMC->version().toString() + "\n\n"); emit log("MultiMC version: " + MMC->version().toString() + "\n\n");
emit log("Minecraft folder is:\n" + workingDirectory() + "\n\n"); emit log("Minecraft folder is:\n" + workingDirectory() + "\n\n");
@ -374,3 +374,17 @@ void MinecraftProcess::launch()
QByteArray bytes = launchScript.toUtf8(); QByteArray bytes = launchScript.toUtf8();
writeData(bytes.constData(), bytes.length()); writeData(bytes.constData(), bytes.length());
} }
void MinecraftProcess::launch()
{
QString launchString("launch\n");
QByteArray bytes = launchString.toUtf8();
writeData(bytes.constData(), bytes.length());
}
void MinecraftProcess::abort()
{
QString launchString("abort\n");
QByteArray bytes = launchString.toUtf8();
writeData(bytes.constData(), bytes.length());
}

View File

@ -55,10 +55,20 @@ public:
MinecraftProcess(BaseInstance *inst); MinecraftProcess(BaseInstance *inst);
/** /**
* @brief launch minecraft * @brief start the launcher part with the provided launch script
*/
void arm();
/**
* @brief launch the armed instance!
*/ */
void launch(); void launch();
/**
* @brief abort launch!
*/
void abort();
BaseInstance *instance() BaseInstance *instance()
{ {
return m_instance; return m_instance;