Analyzer: Merge IAnalyzerEngine and AnalyzerRunControl

Change-Id: I74edaef59600a44924d2692c1ebc7f98d8581115
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
hjk
2013-07-30 14:08:01 +02:00
parent 1fb755bb42
commit 3de45d8c55
35 changed files with 299 additions and 476 deletions

View File

@@ -45,7 +45,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage,
QmlProfilerEngine *engine)
QmlProfilerRunControl *engine)
{
QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
@@ -81,7 +81,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
}
LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration,
QmlProfilerEngine *engine) :
QmlProfilerRunControl *engine) :
AbstractQmlProfilerRunner(engine),
m_configuration(configuration),
m_engine(engine)

View File

@@ -41,7 +41,7 @@ namespace Analyzer { class AnalyzerStartParameters; }
namespace QmlProfiler {
namespace Internal {
class QmlProfilerEngine;
class QmlProfilerRunControl;
class LocalQmlProfilerRunner : public AbstractQmlProfilerRunner
{
Q_OBJECT
@@ -58,7 +58,7 @@ public:
static LocalQmlProfilerRunner *createLocalRunner(ProjectExplorer::RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage,
QmlProfilerEngine *engine);
QmlProfilerRunControl *engine);
~LocalQmlProfilerRunner();
@@ -71,12 +71,12 @@ private slots:
void spontaneousStop(int exitCode);
private:
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerEngine *engine);
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
private:
Configuration m_configuration;
ProjectExplorer::ApplicationLauncher m_launcher;
QmlProfilerEngine *m_engine;
QmlProfilerRunControl *m_engine;
};
} // namespace Internal

View File

@@ -61,15 +61,14 @@ namespace Internal {
// QmlProfilerEnginePrivate
//
class QmlProfilerEngine::QmlProfilerEnginePrivate
class QmlProfilerRunControl::QmlProfilerEnginePrivate
{
public:
QmlProfilerEnginePrivate(const AnalyzerStartParameters &sp) : sp(sp), m_running(false) {}
QmlProfilerEnginePrivate() : m_running(false) {}
QmlProfilerStateManager *m_profilerState;
QTimer m_noDebugOutputTimer;
QmlDebug::QmlOutputParser m_outputParser;
const AnalyzerStartParameters sp;
bool m_running;
};
@@ -77,10 +76,10 @@ public:
// QmlProfilerEngine
//
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
QmlProfilerRunControl::QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate(sp))
: AnalyzerRunControl(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate)
{
d->m_profilerState = 0;
@@ -99,14 +98,14 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
this, SLOT(wrongSetupMessageBox(QString)));
}
QmlProfilerEngine::~QmlProfilerEngine()
QmlProfilerRunControl::~QmlProfilerRunControl()
{
if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning)
stop();
stopEngine();
delete d;
}
bool QmlProfilerEngine::start()
bool QmlProfilerRunControl::startEngine()
{
QTC_ASSERT(d->m_profilerState, return false);
@@ -122,7 +121,7 @@ bool QmlProfilerEngine::start()
}
}
if (d->sp.startMode == StartQmlRemote || d->sp.startMode == StartLocal) {
if (startParameters().startMode == StartQmlRemote || startParameters().startMode == StartLocal) {
d->m_noDebugOutputTimer.start();
} else {
emit processRunning(startParameters().analyzerPort);
@@ -133,7 +132,7 @@ bool QmlProfilerEngine::start()
return true;
}
void QmlProfilerEngine::stop()
void QmlProfilerRunControl::stopEngine()
{
QTC_ASSERT(d->m_profilerState, return);
@@ -158,7 +157,7 @@ void QmlProfilerEngine::stop()
}
}
void QmlProfilerEngine::notifyRemoteFinished(bool success)
void QmlProfilerRunControl::notifyRemoteFinished(bool success)
{
QTC_ASSERT(d->m_profilerState, return);
@@ -170,7 +169,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
AnalyzerManager::stopTool();
engineFinished();
runControlFinished();
break;
}
case QmlProfilerStateManager::AppStopped :
@@ -186,7 +185,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
}
}
void QmlProfilerEngine::cancelProcess()
void QmlProfilerRunControl::cancelProcess()
{
QTC_ASSERT(d->m_profilerState, return);
@@ -206,16 +205,16 @@ void QmlProfilerEngine::cancelProcess()
return;
}
}
engineFinished();
runControlFinished();
}
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
{
emit outputReceived(msg, format);
appendMessage(msg, format);
d->m_outputParser.processOutput(msg);
}
void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage)
{
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
@@ -235,10 +234,10 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
// KILL
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
AnalyzerManager::stopTool();
engineFinished();
runControlFinished();
}
void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
{
if (button == QMessageBox::Help) {
Core::HelpManager *helpManager = Core::HelpManager::instance();
@@ -247,7 +246,7 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
}
}
void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
void QmlProfilerRunControl::showNonmodalWarning(const QString &warningMsg)
{
QMessageBox *noExecWarning = new QMessageBox(Core::ICore::mainWindow());
noExecWarning->setIcon(QMessageBox::Warning);
@@ -259,13 +258,13 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
noExecWarning->show();
}
void QmlProfilerEngine::notifyRemoteSetupDone(quint16 port)
void QmlProfilerRunControl::notifyRemoteSetupDone(quint16 port)
{
d->m_noDebugOutputTimer.stop();
emit processRunning(port);
}
void QmlProfilerEngine::processIsRunning(quint16 port)
void QmlProfilerRunControl::processIsRunning(quint16 port)
{
d->m_noDebugOutputTimer.stop();
@@ -273,13 +272,13 @@ void QmlProfilerEngine::processIsRunning(quint16 port)
emit processRunning(port);
}
void QmlProfilerEngine::engineStarted()
void QmlProfilerRunControl::engineStarted()
{
d->m_running = true;
emit starting(this);
}
void QmlProfilerEngine::engineFinished()
void QmlProfilerRunControl::runControlFinished()
{
d->m_running = false;
emit finished();
@@ -287,7 +286,7 @@ void QmlProfilerEngine::engineFinished()
////////////////////////////////////////////////////////////////
// Profiler State
void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
{
// disconnect old
if (d->m_profilerState)
@@ -300,7 +299,7 @@ void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *p
connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged()));
}
void QmlProfilerEngine::profilerStateChanged()
void QmlProfilerRunControl::profilerStateChanged()
{
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppReadyToStop : {

View File

@@ -32,20 +32,20 @@
#include "qmlprofilerstatemanager.h"
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <utils/outputformat.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerEngine : public Analyzer::IAnalyzerEngine
class QmlProfilerRunControl : public Analyzer::AnalyzerRunControl
{
Q_OBJECT
public:
QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~QmlProfilerEngine();
~QmlProfilerRunControl();
void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
@@ -58,8 +58,8 @@ signals:
void timeUpdate();
public slots:
bool start();
void stop();
bool startEngine();
void stopEngine();
private slots:
void notifyRemoteFinished(bool success = true);
@@ -70,7 +70,7 @@ private slots:
void wrongSetupMessageBoxFinished(int);
void processIsRunning(quint16 port = 0);
void engineStarted();
void engineFinished();
void runControlFinished();
private slots:
void profilerStateChanged();

View File

@@ -131,13 +131,14 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
sp.runMode = mode;
// only desktop device is supported
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
QmlProfilerEngine *engine = qobject_cast<QmlProfilerEngine *>(rc->engine());
AnalyzerRunControl *rc = tool->createRunControl(sp, runConfiguration);
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
if (!engine) {
delete rc;
return 0;
@@ -148,7 +149,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished()));
connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), runner,
connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), runner,
SLOT(start()));
connect(rc, SIGNAL(finished()), runner, SLOT(stop()));
return rc;

View File

@@ -218,10 +218,10 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
return AnyMode;
}
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration);
QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration);
engine->registerProfilerStateManager(d->m_profilerState);
@@ -489,7 +489,8 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
sp.analyzerPort = port;
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
//AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());

View File

@@ -31,7 +31,7 @@
#define QMLPROFILERTOOL_H
#include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
QT_BEGIN_NAMESPACE
class QMessageBox;
@@ -56,7 +56,7 @@ public:
void extensionsInitialized() {}
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,