Fix stuff. Make sure different ways of aborting profiling work.
This commit is contained in:
@ -19,6 +19,21 @@ void BaseProfiler::beginProfiling(MinecraftProcess *process)
|
||||
beginProfilingImpl(process);
|
||||
}
|
||||
|
||||
void BaseProfiler::abortProfiling()
|
||||
{
|
||||
abortProfiling();
|
||||
}
|
||||
|
||||
void BaseProfiler::abortProfilingImpl()
|
||||
{
|
||||
if (!m_profilerProcess)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_profilerProcess->terminate();
|
||||
m_profilerProcess->deleteLater();
|
||||
}
|
||||
|
||||
qint64 BaseProfiler::pid(QProcess *process)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -17,16 +17,20 @@ public:
|
||||
public
|
||||
slots:
|
||||
void beginProfiling(MinecraftProcess *process);
|
||||
void abortProfiling();
|
||||
|
||||
protected:
|
||||
BaseInstance *m_instance;
|
||||
QProcess *m_profilerProcess;
|
||||
|
||||
virtual void beginProfilingImpl(MinecraftProcess *process) = 0;
|
||||
virtual void abortProfilingImpl();
|
||||
|
||||
qint64 pid(QProcess *process);
|
||||
|
||||
signals:
|
||||
void readyToLaunch(const QString &message);
|
||||
void abortLaunch(const QString &message);
|
||||
};
|
||||
|
||||
class BaseProfilerFactory
|
||||
|
@ -22,7 +22,16 @@ void JProfiler::beginProfilingImpl(MinecraftProcess *process)
|
||||
.absoluteFilePath("bin/jpenable"));
|
||||
connect(profiler, &QProcess::started, [this, port]()
|
||||
{ emit readyToLaunch(tr("Listening on port: %1").arg(port)); });
|
||||
connect(profiler, SIGNAL(finished(int)), profiler, SLOT(deleteLater()));
|
||||
connect(profiler,
|
||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||
[this](int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (exit != 0 || status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
m_profilerProcess->deleteLater();
|
||||
});
|
||||
profiler->start();
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,18 @@ void JVisualVM::beginProfilingImpl(MinecraftProcess *process)
|
||||
profiler->setProgram("jvisualvm");
|
||||
connect(profiler, &QProcess::started, [this]()
|
||||
{ emit readyToLaunch(tr("JVisualVM started")); });
|
||||
connect(profiler, SIGNAL(finished(int)), profiler, SLOT(deleteLater()));
|
||||
connect(profiler,
|
||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||
[this](int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (exit != 0 || status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
m_profilerProcess->deleteLater();
|
||||
});
|
||||
profiler->start();
|
||||
m_profilerProcess = profiler;
|
||||
}
|
||||
|
||||
void JVisualVMFactory::registerSettings(SettingsObject *settings)
|
||||
|
Reference in New Issue
Block a user