summaryrefslogtreecommitdiffstats
path: root/gui/MainWindow.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-02-15 14:19:35 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-02-15 14:19:35 +0100
commitefa8e26a3f3f7ba5e536cd10e86303b4fe1baba0 (patch)
tree4fcd3e9f210c92dbeac9f820f2ab1fd2d6dd9e58 /gui/MainWindow.cpp
parent5cf599673db88b39100ffca78e10bbe5e10200d7 (diff)
downloadMultiMC-efa8e26a3f3f7ba5e536cd10e86303b4fe1baba0.tar
MultiMC-efa8e26a3f3f7ba5e536cd10e86303b4fe1baba0.tar.gz
MultiMC-efa8e26a3f3f7ba5e536cd10e86303b4fe1baba0.tar.lz
MultiMC-efa8e26a3f3f7ba5e536cd10e86303b4fe1baba0.tar.xz
MultiMC-efa8e26a3f3f7ba5e536cd10e86303b4fe1baba0.zip
Profiler support. Currently JProfiler and JVisualVM are implemented.
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r--gui/MainWindow.cpp56
1 files changed, 48 insertions, 8 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 29f7c8e8..ddeb9947 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -33,6 +33,7 @@
#include <QLabel>
#include <QToolButton>
#include <QWidgetAction>
+#include <QProgressDialog>
#include "osutils.h"
#include "userutils.h"
@@ -97,6 +98,9 @@
#include <logic/updater/NotificationChecker.h>
#include <logic/tasks/ThreadTask.h>
+#include "logic/profiler/BaseProfiler.h"
+#include "logic/OneSixInstance.h"
+
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
MultiMCPlatform::fixWM_CLASS(this);
@@ -1078,7 +1082,7 @@ void MainWindow::on_actionLaunchInstanceOffline_triggered()
}
}
-void MainWindow::doLaunch(bool online)
+void MainWindow::doLaunch(bool online, bool profile)
{
if (!m_selectedInstance)
return;
@@ -1194,11 +1198,11 @@ void MainWindow::doLaunch(bool online)
// update first if the server actually responded
if (session->auth_server_online)
{
- updateInstance(m_selectedInstance, session);
+ updateInstance(m_selectedInstance, session, profile);
}
else
{
- launchInstance(m_selectedInstance, session);
+ launchInstance(m_selectedInstance, session, profile);
}
tryagain = false;
}
@@ -1206,22 +1210,22 @@ void MainWindow::doLaunch(bool online)
}
}
-void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session)
+void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session, bool profile)
{
auto updateTask = instance->doUpdate();
if (!updateTask)
{
- launchInstance(instance, session);
+ launchInstance(instance, session, profile);
return;
}
ProgressDialog tDialog(this);
- connect(updateTask.get(), &Task::succeeded, [this, instance, session]
- { launchInstance(instance, session); });
+ connect(updateTask.get(), &Task::succeeded, [this, instance, session, profile]
+ { launchInstance(instance, session, profile); });
connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
tDialog.exec(updateTask.get());
}
-void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session)
+void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session, bool profile)
{
Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL");
Q_ASSERT_X(session.get() != nullptr, "launchInstance", "session is NULL");
@@ -1237,6 +1241,33 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session)
proc->setLogin(session);
proc->launch();
+
+ if (profile && qobject_cast<OneSixInstance *>(instance))
+ {
+ BaseProfiler *profiler = MMC->currentProfiler()->createProfiler(
+ qobject_cast<OneSixInstance *>(instance), this);
+ QProgressDialog dialog;
+ dialog.setMinimum(0);
+ dialog.setMaximum(0);
+ dialog.setValue(0);
+ dialog.setLabelText(tr("Waiting for profiler..."));
+ dialog.show();
+ connect(profiler, &BaseProfiler::readyToLaunch, [&dialog, this](const QString &message)
+ {
+ dialog.accept();
+ QMessageBox msg;
+ msg.setText(tr("The launch of Minecraft itself 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->write("launch onesix\n");
+ });
+ profiler->beginProfiling(proc);
+ dialog.exec();
+ }
}
void MainWindow::onGameUpdateError(QString error)
@@ -1416,6 +1447,15 @@ void MainWindow::on_actionEditInstNotes_triggered()
}
}
+void MainWindow::on_actionProfileInstance_triggered()
+{
+ if (m_selectedInstance)
+ {
+ NagUtils::checkJVMArgs(m_selectedInstance->settings().get("JvmArgs").toString(), this);
+ doLaunch(true, true);
+ }
+}
+
void MainWindow::instanceEnded()
{
this->show();