NOISSUE fix profilers
This commit is contained in:
parent
3d3725f088
commit
58840ac10c
@ -1832,58 +1832,48 @@ void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session,
|
|||||||
proc->setHeader("MultiMC version: " + BuildConfig.printableVersionString() + "\n\n");
|
proc->setHeader("MultiMC version: " + BuildConfig.printableVersionString() + "\n\n");
|
||||||
proc->arm();
|
proc->arm();
|
||||||
|
|
||||||
if (profiler)
|
if (!profiler)
|
||||||
{
|
|
||||||
QString error;
|
|
||||||
if (!profiler->check(&error))
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"),
|
|
||||||
tr("Couldn't start profiler: %1").arg(error));
|
|
||||||
proc->abort();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BaseProfiler *profilerInstance = profiler->createProfiler(instance, this);
|
|
||||||
QProgressDialog dialog;
|
|
||||||
dialog.setMinimum(0);
|
|
||||||
dialog.setMaximum(0);
|
|
||||||
dialog.setValue(0);
|
|
||||||
dialog.setLabelText(tr("Waiting for profiler..."));
|
|
||||||
connect(&dialog, &QProgressDialog::canceled, profilerInstance,
|
|
||||||
&BaseProfiler::abortProfiling);
|
|
||||||
dialog.show();
|
|
||||||
connect(profilerInstance, &BaseProfiler::readyToLaunch,
|
|
||||||
[&dialog, this, proc](const QString & message)
|
|
||||||
{
|
|
||||||
dialog.accept();
|
|
||||||
QMessageBox msg;
|
|
||||||
msg.setText(tr("The game launch is delayed until you press the "
|
|
||||||
"button. This is the right time to setup the profiler, as the "
|
|
||||||
"profiler server is running now.\n\n%1").arg(message));
|
|
||||||
msg.setWindowTitle(tr("Waiting"));
|
|
||||||
msg.setIcon(QMessageBox::Information);
|
|
||||||
msg.addButton(tr("Launch"), QMessageBox::AcceptRole);
|
|
||||||
msg.exec();
|
|
||||||
proc->launch();
|
|
||||||
});
|
|
||||||
connect(profilerInstance, &BaseProfiler::abortLaunch,
|
|
||||||
[&dialog, this, proc](const QString & message)
|
|
||||||
{
|
|
||||||
dialog.accept();
|
|
||||||
QMessageBox msg;
|
|
||||||
msg.setText(tr("Couldn't start the profiler: %1").arg(message));
|
|
||||||
msg.setWindowTitle(tr("Error"));
|
|
||||||
msg.setIcon(QMessageBox::Critical);
|
|
||||||
msg.addButton(QMessageBox::Ok);
|
|
||||||
msg.exec();
|
|
||||||
proc->abort();
|
|
||||||
});
|
|
||||||
profilerInstance->beginProfiling(proc);
|
|
||||||
dialog.exec();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
proc->launch();
|
proc->launch();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString error;
|
||||||
|
if (!profiler->check(&error))
|
||||||
|
{
|
||||||
|
proc->abort();
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't start profiler: %1").arg(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BaseProfiler *profilerInstance = profiler->createProfiler(instance, this);
|
||||||
|
|
||||||
|
connect(profilerInstance, &BaseProfiler::readyToLaunch,
|
||||||
|
[this, proc](const QString & message)
|
||||||
|
{
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setText(tr("The game launch is delayed until you press the "
|
||||||
|
"button. This is the right time to setup the profiler, as the "
|
||||||
|
"profiler server is running now.\n\n%1").arg(message));
|
||||||
|
msg.setWindowTitle(tr("Waiting"));
|
||||||
|
msg.setIcon(QMessageBox::Information);
|
||||||
|
msg.addButton(tr("Launch"), QMessageBox::AcceptRole);
|
||||||
|
msg.setModal(true);
|
||||||
|
msg.exec();
|
||||||
|
proc->launch();
|
||||||
|
});
|
||||||
|
connect(profilerInstance, &BaseProfiler::abortLaunch,
|
||||||
|
[this, proc](const QString & message)
|
||||||
|
{
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setText(tr("Couldn't start the profiler: %1").arg(message));
|
||||||
|
msg.setWindowTitle(tr("Error"));
|
||||||
|
msg.setIcon(QMessageBox::Critical);
|
||||||
|
msg.addButton(QMessageBox::Ok);
|
||||||
|
msg.setModal(true);
|
||||||
|
msg.exec();
|
||||||
|
proc->abort();
|
||||||
|
});
|
||||||
|
profilerInstance->beginProfiling(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onGameUpdateError(QString error)
|
void MainWindow::onGameUpdateError(QString error)
|
||||||
|
@ -7,42 +7,73 @@
|
|||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
|
class JProfiler : public BaseProfiler
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void profilerStarted();
|
||||||
|
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void beginProfilingImpl(BaseProcess *process);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int listeningPort = 0;
|
||||||
|
};
|
||||||
|
|
||||||
JProfiler::JProfiler(SettingsObjectPtr settings, InstancePtr instance,
|
JProfiler::JProfiler(SettingsObjectPtr settings, InstancePtr instance,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: BaseProfiler(settings, instance, parent)
|
: BaseProfiler(settings, instance, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JProfiler::profilerStarted()
|
||||||
|
{
|
||||||
|
emit readyToLaunch(tr("Listening on port: %1").arg(listeningPort));
|
||||||
|
}
|
||||||
|
|
||||||
|
void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||||
|
{
|
||||||
|
if (status == QProcess::CrashExit)
|
||||||
|
{
|
||||||
|
emit abortLaunch(tr("Profiler aborted"));
|
||||||
|
}
|
||||||
|
if (m_profilerProcess)
|
||||||
|
{
|
||||||
|
m_profilerProcess->deleteLater();
|
||||||
|
m_profilerProcess = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void JProfiler::beginProfilingImpl(BaseProcess *process)
|
void JProfiler::beginProfilingImpl(BaseProcess *process)
|
||||||
{
|
{
|
||||||
int port = globalSettings->get("JProfilerPort").toInt();
|
listeningPort = globalSettings->get("JProfilerPort").toInt();
|
||||||
QProcess *profiler = new QProcess(this);
|
QProcess *profiler = new QProcess(this);
|
||||||
profiler->setArguments(QStringList() << "-d" << QString::number(pid(process)) << "--gui"
|
QStringList profilerArgs =
|
||||||
<< "-p" << QString::number(port));
|
|
||||||
profiler->setProgram(QDir(globalSettings->get("JProfilerPath").toString())
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
.absoluteFilePath("bin/jpenable.exe"));
|
|
||||||
#else
|
|
||||||
.absoluteFilePath("bin/jpenable"));
|
|
||||||
#endif
|
|
||||||
connect(profiler, &QProcess::started, [this, port]()
|
|
||||||
{ emit readyToLaunch(tr("Listening on port: %1").arg(port)); });
|
|
||||||
connect(profiler,
|
|
||||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
|
||||||
[this](int exit, QProcess::ExitStatus status)
|
|
||||||
{
|
{
|
||||||
if (status == QProcess::CrashExit)
|
"-d", QString::number(pid(process)),
|
||||||
{
|
"--gui",
|
||||||
emit abortLaunch(tr("Profiler aborted"));
|
"-p", QString::number(listeningPort)
|
||||||
}
|
};
|
||||||
if (m_profilerProcess)
|
auto basePath = globalSettings->get("JProfilerPath").toString();
|
||||||
{
|
|
||||||
m_profilerProcess->deleteLater();
|
#ifdef Q_OS_WIN
|
||||||
m_profilerProcess = 0;
|
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable.exe");
|
||||||
}
|
#else
|
||||||
});
|
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable");
|
||||||
profiler->start();
|
#endif
|
||||||
|
|
||||||
|
profiler->setArguments(profilerArgs);
|
||||||
|
profiler->setProgram(profilerProgram);
|
||||||
|
|
||||||
|
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||||
|
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||||
|
|
||||||
m_profilerProcess = profiler;
|
m_profilerProcess = profiler;
|
||||||
|
profiler->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JProfilerFactory::registerSettings(SettingsObjectPtr settings)
|
void JProfilerFactory::registerSettings(SettingsObjectPtr settings)
|
||||||
@ -82,3 +113,5 @@ bool JProfilerFactory::check(const QString &path, QString *error)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "JProfiler.moc"
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
#include "BaseProfiler.h"
|
#include "BaseProfiler.h"
|
||||||
|
|
||||||
class JProfiler : public BaseProfiler
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void beginProfilingImpl(BaseProcess *process);
|
|
||||||
};
|
|
||||||
|
|
||||||
class JProfilerFactory : public BaseProfilerFactory
|
class JProfilerFactory : public BaseProfilerFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -7,32 +7,59 @@
|
|||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
|
class JVisualVM : public BaseProfiler
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void profilerStarted();
|
||||||
|
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void beginProfilingImpl(BaseProcess *process);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
JVisualVM::JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
JVisualVM::JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
||||||
: BaseProfiler(settings, instance, parent)
|
: BaseProfiler(settings, instance, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JVisualVM::profilerStarted()
|
||||||
|
{
|
||||||
|
emit readyToLaunch(tr("JVisualVM started"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||||
|
{
|
||||||
|
if (status == QProcess::CrashExit)
|
||||||
|
{
|
||||||
|
emit abortLaunch(tr("Profiler aborted"));
|
||||||
|
}
|
||||||
|
if (m_profilerProcess)
|
||||||
|
{
|
||||||
|
m_profilerProcess->deleteLater();
|
||||||
|
m_profilerProcess = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void JVisualVM::beginProfilingImpl(BaseProcess *process)
|
void JVisualVM::beginProfilingImpl(BaseProcess *process)
|
||||||
{
|
{
|
||||||
QProcess *profiler = new QProcess(this);
|
QProcess *profiler = new QProcess(this);
|
||||||
profiler->setArguments(QStringList() << "--openpid" << QString::number(pid(process)));
|
QStringList profilerArgs =
|
||||||
profiler->setProgram(globalSettings->get("JVisualVMPath").toString());
|
|
||||||
connect(profiler, &QProcess::started, [this]()
|
|
||||||
{ emit readyToLaunch(tr("JVisualVM started")); });
|
|
||||||
connect(profiler,
|
|
||||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
|
||||||
[this](int exit, QProcess::ExitStatus status)
|
|
||||||
{
|
{
|
||||||
if (exit != 0 || status == QProcess::CrashExit)
|
"--openpid", QString::number(pid(process))
|
||||||
{
|
};
|
||||||
emit abortLaunch(tr("Profiler aborted"));
|
auto programPath = globalSettings->get("JVisualVMPath").toString();
|
||||||
}
|
|
||||||
if (m_profilerProcess)
|
profiler->setArguments(profilerArgs);
|
||||||
{
|
profiler->setProgram(programPath);
|
||||||
m_profilerProcess->deleteLater();
|
|
||||||
m_profilerProcess = 0;
|
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||||
}
|
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||||
});
|
|
||||||
profiler->start();
|
profiler->start();
|
||||||
m_profilerProcess = profiler;
|
m_profilerProcess = profiler;
|
||||||
}
|
}
|
||||||
@ -72,3 +99,5 @@ bool JVisualVMFactory::check(const QString &path, QString *error)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "JVisualVM.moc"
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
#include "BaseProfiler.h"
|
#include "BaseProfiler.h"
|
||||||
|
|
||||||
class JVisualVM : public BaseProfiler
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void beginProfilingImpl(BaseProcess *process);
|
|
||||||
};
|
|
||||||
|
|
||||||
class JVisualVMFactory : public BaseProfilerFactory
|
class JVisualVMFactory : public BaseProfilerFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user