Try to be cross-platform

This commit is contained in:
Jan Dalheimer 2014-02-15 18:15:41 +01:00
parent 6f6d912d07
commit c0e58fbfb2
3 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,7 @@
#include "BaseProfiler.h" #include "BaseProfiler.h"
#include <QProcess>
BaseProfiler::BaseProfiler(OneSixInstance *instance, QObject *parent) BaseProfiler::BaseProfiler(OneSixInstance *instance, QObject *parent)
: QObject(parent), m_instance(instance) : QObject(parent), m_instance(instance)
{ {
@ -14,6 +16,15 @@ void BaseProfiler::beginProfiling(MinecraftProcess *process)
beginProfilingImpl(process); beginProfilingImpl(process);
} }
qint64 BaseProfiler::pid(QProcess *process)
{
#ifdef Q_OS_UNIX
return process->pid();
#else
return (qint64)process->pid();
#endif
}
BaseProfilerFactory::~BaseProfilerFactory() BaseProfilerFactory::~BaseProfilerFactory()
{ {
} }

View File

@ -5,6 +5,7 @@
class OneSixInstance; class OneSixInstance;
class SettingsObject; class SettingsObject;
class MinecraftProcess; class MinecraftProcess;
class QProcess;
class BaseProfiler : public QObject class BaseProfiler : public QObject
{ {
@ -22,6 +23,8 @@ protected:
virtual void beginProfilingImpl(MinecraftProcess *process) = 0; virtual void beginProfilingImpl(MinecraftProcess *process) = 0;
qint64 pid(QProcess *process);
signals: signals:
void readyToLaunch(const QString &message); void readyToLaunch(const QString &message);
}; };

View File

@ -16,7 +16,7 @@ void JProfiler::beginProfilingImpl(MinecraftProcess *process)
{ {
int port = MMC->settings()->get("JProfilerPort").toInt(); int port = MMC->settings()->get("JProfilerPort").toInt();
QProcess *profiler = new QProcess(this); 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)); << "-p" << QString::number(port));
profiler->setProgram(QDir(MMC->settings()->get("JProfilerPath").toString()) profiler->setProgram(QDir(MMC->settings()->get("JProfilerPath").toString())
.absoluteFilePath("bin/jpenable")); .absoluteFilePath("bin/jpenable"));