From 994972bf5da5584186e6e82c36287afeb6c1e23a Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sun, 16 Feb 2014 09:30:38 +0100 Subject: [PATCH] More fixes. --- gui/MainWindow.cpp | 2 +- logic/profiler/BaseProfiler.cpp | 4 +++- logic/profiler/JProfiler.cpp | 9 +++++++-- logic/profiler/JVisualVM.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index b28e753f4..b05c58f74 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1256,7 +1256,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session, dialog.setMaximum(0); dialog.setValue(0); dialog.setLabelText(tr("Waiting for profiler...")); - connect(&dialog, &QDialog::rejected, profilerInstance, &BaseProfiler::abortProfiling); + connect(&dialog, &QProgressDialog::canceled, profilerInstance, &BaseProfiler::abortProfiling); dialog.show(); connect(profilerInstance, &BaseProfiler::readyToLaunch, [&dialog, this](const QString &message) { diff --git a/logic/profiler/BaseProfiler.cpp b/logic/profiler/BaseProfiler.cpp index 1a3778188..b58e88be9 100644 --- a/logic/profiler/BaseProfiler.cpp +++ b/logic/profiler/BaseProfiler.cpp @@ -21,7 +21,7 @@ void BaseProfiler::beginProfiling(MinecraftProcess *process) void BaseProfiler::abortProfiling() { - abortProfiling(); + abortProfilingImpl(); } void BaseProfiler::abortProfilingImpl() @@ -32,6 +32,8 @@ void BaseProfiler::abortProfilingImpl() } m_profilerProcess->terminate(); m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + emit abortLaunch(tr("Profiler aborted")); } qint64 BaseProfiler::pid(QProcess *process) diff --git a/logic/profiler/JProfiler.cpp b/logic/profiler/JProfiler.cpp index 34f927cec..1cd8d1282 100644 --- a/logic/profiler/JProfiler.cpp +++ b/logic/profiler/JProfiler.cpp @@ -26,13 +26,18 @@ void JProfiler::beginProfilingImpl(MinecraftProcess *process) static_cast(&QProcess::finished), [this](int exit, QProcess::ExitStatus status) { - if (exit != 0 || status == QProcess::CrashExit) + if (status == QProcess::CrashExit) { emit abortLaunch(tr("Profiler aborted")); } - m_profilerProcess->deleteLater(); + if (m_profilerProcess) + { + m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + } }); profiler->start(); + m_profilerProcess = profiler; } void JProfilerFactory::registerSettings(SettingsObject *settings) diff --git a/logic/profiler/JVisualVM.cpp b/logic/profiler/JVisualVM.cpp index 89098f73b..c4bc851bc 100644 --- a/logic/profiler/JVisualVM.cpp +++ b/logic/profiler/JVisualVM.cpp @@ -16,7 +16,7 @@ void JVisualVM::beginProfilingImpl(MinecraftProcess *process) { QProcess *profiler = new QProcess(this); profiler->setArguments(QStringList() << "--openpid" << QString::number(pid(process))); - profiler->setProgram("jvisualvm"); + profiler->setProgram(MMC->settings()->get("JVisualVMPath").toString()); connect(profiler, &QProcess::started, [this]() { emit readyToLaunch(tr("JVisualVM started")); }); connect(profiler, @@ -27,7 +27,11 @@ void JVisualVM::beginProfilingImpl(MinecraftProcess *process) { emit abortLaunch(tr("Profiler aborted")); } - m_profilerProcess->deleteLater(); + if (m_profilerProcess) + { + m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + } }); profiler->start(); m_profilerProcess = profiler;