Fix stuff. Make sure different ways of aborting profiling work.
This commit is contained in:
parent
7ceb2cacb1
commit
82b35b5445
@ -1256,6 +1256,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session,
|
|||||||
dialog.setMaximum(0);
|
dialog.setMaximum(0);
|
||||||
dialog.setValue(0);
|
dialog.setValue(0);
|
||||||
dialog.setLabelText(tr("Waiting for profiler..."));
|
dialog.setLabelText(tr("Waiting for profiler..."));
|
||||||
|
connect(&dialog, &QDialog::rejected, profilerInstance, &BaseProfiler::abortProfiling);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
connect(profilerInstance, &BaseProfiler::readyToLaunch, [&dialog, this](const QString &message)
|
connect(profilerInstance, &BaseProfiler::readyToLaunch, [&dialog, this](const QString &message)
|
||||||
{
|
{
|
||||||
@ -1270,6 +1271,17 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session,
|
|||||||
msg.exec();
|
msg.exec();
|
||||||
proc->launch();
|
proc->launch();
|
||||||
});
|
});
|
||||||
|
connect(profilerInstance, &BaseProfiler::abortLaunch, [&dialog, this](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);
|
profilerInstance->beginProfiling(proc);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset>
|
<iconset resource="../../graphics.qrc">
|
||||||
<normaloff>:/icons/toolbar/settings</normaloff>:/icons/toolbar/settings</iconset>
|
<normaloff>:/icons/toolbar/settings</normaloff>:/icons/toolbar/settings</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="featuresTab">
|
<widget class="QWidget" name="featuresTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -980,7 +980,9 @@
|
|||||||
<tabstop>postExitCmdTextBox</tabstop>
|
<tabstop>postExitCmdTextBox</tabstop>
|
||||||
<tabstop>settingsTabs</tabstop>
|
<tabstop>settingsTabs</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../graphics.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
@ -19,6 +19,21 @@ void BaseProfiler::beginProfiling(MinecraftProcess *process)
|
|||||||
beginProfilingImpl(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)
|
qint64 BaseProfiler::pid(QProcess *process)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -17,16 +17,20 @@ public:
|
|||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void beginProfiling(MinecraftProcess *process);
|
void beginProfiling(MinecraftProcess *process);
|
||||||
|
void abortProfiling();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseInstance *m_instance;
|
BaseInstance *m_instance;
|
||||||
|
QProcess *m_profilerProcess;
|
||||||
|
|
||||||
virtual void beginProfilingImpl(MinecraftProcess *process) = 0;
|
virtual void beginProfilingImpl(MinecraftProcess *process) = 0;
|
||||||
|
virtual void abortProfilingImpl();
|
||||||
|
|
||||||
qint64 pid(QProcess *process);
|
qint64 pid(QProcess *process);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void readyToLaunch(const QString &message);
|
void readyToLaunch(const QString &message);
|
||||||
|
void abortLaunch(const QString &message);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BaseProfilerFactory
|
class BaseProfilerFactory
|
||||||
|
@ -22,7 +22,16 @@ void JProfiler::beginProfilingImpl(MinecraftProcess *process)
|
|||||||
.absoluteFilePath("bin/jpenable"));
|
.absoluteFilePath("bin/jpenable"));
|
||||||
connect(profiler, &QProcess::started, [this, port]()
|
connect(profiler, &QProcess::started, [this, port]()
|
||||||
{ emit readyToLaunch(tr("Listening on port: %1").arg(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();
|
profiler->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,18 @@ void JVisualVM::beginProfilingImpl(MinecraftProcess *process)
|
|||||||
profiler->setProgram("jvisualvm");
|
profiler->setProgram("jvisualvm");
|
||||||
connect(profiler, &QProcess::started, [this]()
|
connect(profiler, &QProcess::started, [this]()
|
||||||
{ emit readyToLaunch(tr("JVisualVM started")); });
|
{ 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();
|
profiler->start();
|
||||||
|
m_profilerProcess = profiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JVisualVMFactory::registerSettings(SettingsObject *settings)
|
void JVisualVMFactory::registerSettings(SettingsObject *settings)
|
||||||
|
Loading…
Reference in New Issue
Block a user