summaryrefslogtreecommitdiffstats
path: root/logic/profiler
diff options
context:
space:
mode:
Diffstat (limited to 'logic/profiler')
-rw-r--r--logic/profiler/BaseProfiler.cpp2
-rw-r--r--logic/profiler/BaseProfiler.h11
-rw-r--r--logic/profiler/JProfiler.cpp16
-rw-r--r--logic/profiler/JProfiler.h6
-rw-r--r--logic/profiler/JVisualVM.cpp17
-rw-r--r--logic/profiler/JVisualVM.h6
6 files changed, 43 insertions, 15 deletions
diff --git a/logic/profiler/BaseProfiler.cpp b/logic/profiler/BaseProfiler.cpp
index 94891fc4..4765c67d 100644
--- a/logic/profiler/BaseProfiler.cpp
+++ b/logic/profiler/BaseProfiler.cpp
@@ -5,7 +5,7 @@
#include <windows.h>
#endif
-BaseProfiler::BaseProfiler(OneSixInstance *instance, QObject *parent)
+BaseProfiler::BaseProfiler(BaseInstance *instance, QObject *parent)
: QObject(parent), m_instance(instance)
{
}
diff --git a/logic/profiler/BaseProfiler.h b/logic/profiler/BaseProfiler.h
index e7bc4c2d..4c5f63fc 100644
--- a/logic/profiler/BaseProfiler.h
+++ b/logic/profiler/BaseProfiler.h
@@ -2,7 +2,7 @@
#include <QObject>
-class OneSixInstance;
+class BaseInstance;
class SettingsObject;
class MinecraftProcess;
class QProcess;
@@ -11,7 +11,7 @@ class BaseProfiler : public QObject
{
Q_OBJECT
public:
- explicit BaseProfiler(OneSixInstance *instance, QObject *parent = 0);
+ explicit BaseProfiler(BaseInstance *instance, QObject *parent = 0);
virtual ~BaseProfiler();
public
@@ -19,7 +19,7 @@ slots:
void beginProfiling(MinecraftProcess *process);
protected:
- OneSixInstance *m_instance;
+ BaseInstance *m_instance;
virtual void beginProfilingImpl(MinecraftProcess *process) = 0;
@@ -34,9 +34,12 @@ class BaseProfilerFactory
public:
virtual ~BaseProfilerFactory();
+ virtual QString name() const = 0;
+
virtual void registerSettings(SettingsObject *settings) = 0;
- virtual BaseProfiler *createProfiler(OneSixInstance *instance, QObject *parent = 0) = 0;
+ virtual BaseProfiler *createProfiler(BaseInstance *instance, QObject *parent = 0) = 0;
+ virtual bool check(QString *error) = 0;
virtual bool check(const QString &path, QString *error) = 0;
};
diff --git a/logic/profiler/JProfiler.cpp b/logic/profiler/JProfiler.cpp
index eddf46d9..cec614ae 100644
--- a/logic/profiler/JProfiler.cpp
+++ b/logic/profiler/JProfiler.cpp
@@ -5,10 +5,10 @@
#include "settingsobject.h"
#include "logic/MinecraftProcess.h"
-#include "logic/OneSixInstance.h"
+#include "logic/BaseInstance.h"
#include "MultiMC.h"
-JProfiler::JProfiler(OneSixInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
+JProfiler::JProfiler(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
{
}
@@ -32,13 +32,23 @@ void JProfilerFactory::registerSettings(SettingsObject *settings)
settings->registerSetting("JProfilerPort", 42042);
}
-BaseProfiler *JProfilerFactory::createProfiler(OneSixInstance *instance, QObject *parent)
+BaseProfiler *JProfilerFactory::createProfiler(BaseInstance *instance, QObject *parent)
{
return new JProfiler(instance, parent);
}
+bool JProfilerFactory::check(QString *error)
+{
+ return check(MMC->settings()->get("JProfilerPath").toString(), error);
+}
+
bool JProfilerFactory::check(const QString &path, QString *error)
{
+ if (path.isEmpty())
+ {
+ *error = QObject::tr("Empty path");
+ return false;
+ }
QDir dir(path);
if (!dir.exists())
{
diff --git a/logic/profiler/JProfiler.h b/logic/profiler/JProfiler.h
index 9fa3591a..8a5bc561 100644
--- a/logic/profiler/JProfiler.h
+++ b/logic/profiler/JProfiler.h
@@ -6,7 +6,7 @@ class JProfiler : public BaseProfiler
{
Q_OBJECT
public:
- JProfiler(OneSixInstance *instance, QObject *parent = 0);
+ JProfiler(BaseInstance *instance, QObject *parent = 0);
protected:
void beginProfilingImpl(MinecraftProcess *process);
@@ -15,7 +15,9 @@ protected:
class JProfilerFactory : public BaseProfilerFactory
{
public:
+ QString name() const override { return "JProfiler"; }
void registerSettings(SettingsObject *settings) override;
- BaseProfiler *createProfiler(OneSixInstance *instance, QObject *parent = 0) override;
+ BaseProfiler *createProfiler(BaseInstance *instance, QObject *parent = 0) override;
+ bool check(QString *error) override;
bool check(const QString &path, QString *error) override;
};
diff --git a/logic/profiler/JVisualVM.cpp b/logic/profiler/JVisualVM.cpp
index a1aa6951..3850ff40 100644
--- a/logic/profiler/JVisualVM.cpp
+++ b/logic/profiler/JVisualVM.cpp
@@ -5,9 +5,10 @@
#include "settingsobject.h"
#include "logic/MinecraftProcess.h"
-#include "logic/OneSixInstance.h"
+#include "logic/BaseInstance.h"
+#include "MultiMC.h"
-JVisualVM::JVisualVM(OneSixInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
+JVisualVM::JVisualVM(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
{
}
@@ -27,13 +28,23 @@ void JVisualVMFactory::registerSettings(SettingsObject *settings)
settings->registerSetting("JVisualVMPath");
}
-BaseProfiler *JVisualVMFactory::createProfiler(OneSixInstance *instance, QObject *parent)
+BaseProfiler *JVisualVMFactory::createProfiler(BaseInstance *instance, QObject *parent)
{
return new JVisualVM(instance, parent);
}
+bool JVisualVMFactory::check(QString *error)
+{
+ return check(MMC->settings()->get("JVisualVMPath").toString(), error);
+}
+
bool JVisualVMFactory::check(const QString &path, QString *error)
{
+ if (path.isEmpty())
+ {
+ *error = QObject::tr("Empty path");
+ return false;
+ }
QString resolved = QStandardPaths::findExecutable(path);
if (resolved.isEmpty() && !QDir::isAbsolutePath(path))
{
diff --git a/logic/profiler/JVisualVM.h b/logic/profiler/JVisualVM.h
index e72b75d9..154180b4 100644
--- a/logic/profiler/JVisualVM.h
+++ b/logic/profiler/JVisualVM.h
@@ -6,7 +6,7 @@ class JVisualVM : public BaseProfiler
{
Q_OBJECT
public:
- JVisualVM(OneSixInstance *instance, QObject *parent = 0);
+ JVisualVM(BaseInstance *instance, QObject *parent = 0);
protected:
void beginProfilingImpl(MinecraftProcess *process);
@@ -15,7 +15,9 @@ protected:
class JVisualVMFactory : public BaseProfilerFactory
{
public:
+ QString name() const override { return "JVisualVM"; }
void registerSettings(SettingsObject *settings) override;
- BaseProfiler *createProfiler(OneSixInstance *instance, QObject *parent = 0) override;
+ BaseProfiler *createProfiler(BaseInstance *instance, QObject *parent = 0) override;
+ bool check(QString *error) override;
bool check(const QString &path, QString *error) override;
};