From c0e58fbfb213c05f0259dab9bf5b7aabd6f373cf Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sat, 15 Feb 2014 18:15:41 +0100 Subject: [PATCH] Try to be cross-platform --- logic/profiler/BaseProfiler.cpp | 11 +++++++++++ logic/profiler/BaseProfiler.h | 3 +++ logic/profiler/JProfiler.cpp | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/logic/profiler/BaseProfiler.cpp b/logic/profiler/BaseProfiler.cpp index 788e9614..7934f6b4 100644 --- a/logic/profiler/BaseProfiler.cpp +++ b/logic/profiler/BaseProfiler.cpp @@ -1,5 +1,7 @@ #include "BaseProfiler.h" +#include + BaseProfiler::BaseProfiler(OneSixInstance *instance, QObject *parent) : QObject(parent), m_instance(instance) { @@ -14,6 +16,15 @@ void BaseProfiler::beginProfiling(MinecraftProcess *process) beginProfilingImpl(process); } +qint64 BaseProfiler::pid(QProcess *process) +{ +#ifdef Q_OS_UNIX + return process->pid(); +#else + return (qint64)process->pid(); +#endif +} + BaseProfilerFactory::~BaseProfilerFactory() { } diff --git a/logic/profiler/BaseProfiler.h b/logic/profiler/BaseProfiler.h index 2986c8e1..e7bc4c2d 100644 --- a/logic/profiler/BaseProfiler.h +++ b/logic/profiler/BaseProfiler.h @@ -5,6 +5,7 @@ class OneSixInstance; class SettingsObject; class MinecraftProcess; +class QProcess; class BaseProfiler : public QObject { @@ -22,6 +23,8 @@ protected: virtual void beginProfilingImpl(MinecraftProcess *process) = 0; + qint64 pid(QProcess *process); + signals: void readyToLaunch(const QString &message); }; diff --git a/logic/profiler/JProfiler.cpp b/logic/profiler/JProfiler.cpp index aa6a866a..eddf46d9 100644 --- a/logic/profiler/JProfiler.cpp +++ b/logic/profiler/JProfiler.cpp @@ -16,7 +16,7 @@ void JProfiler::beginProfilingImpl(MinecraftProcess *process) { int port = MMC->settings()->get("JProfilerPort").toInt(); QProcess *profiler = new QProcess(this); - profiler->setArguments(QStringList() << "-d" << QString::number(process->pid()) << "--gui" + profiler->setArguments(QStringList() << "-d" << QString::number(pid(process)) << "--gui" << "-p" << QString::number(port)); profiler->setProgram(QDir(MMC->settings()->get("JProfilerPath").toString()) .absoluteFilePath("bin/jpenable"));