forked from qt-creator/qt-creator
QmlProfiler: clean up QmlProfiler{State,Client}Manager
Change-Id: I538fbae5be9750b9b00f82d467136a8500e8f8e6 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
@@ -46,11 +46,10 @@ using namespace Core;
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlProfilerClientManager::QmlProfilerClientManagerPrivate {
|
class QmlProfilerClientManager::QmlProfilerClientManagerPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerClientManagerPrivate(QmlProfilerClientManager *qq) { Q_UNUSED(qq); }
|
QmlProfilerStateManager *profilerState;
|
||||||
|
|
||||||
QmlProfilerStateManager* profilerState;
|
|
||||||
|
|
||||||
QmlDebugConnection *connection;
|
QmlDebugConnection *connection;
|
||||||
QPointer<QmlProfilerTraceClient> qmlclientplugin;
|
QPointer<QmlProfilerTraceClient> qmlclientplugin;
|
||||||
@@ -59,9 +58,7 @@ public:
|
|||||||
QTimer connectionTimer;
|
QTimer connectionTimer;
|
||||||
int connectionAttempts;
|
int connectionAttempts;
|
||||||
|
|
||||||
enum ConnectMode {
|
enum ConnectMode { TcpConnection, OstConnection };
|
||||||
TcpConnection, OstConnection
|
|
||||||
};
|
|
||||||
ConnectMode connectMode;
|
ConnectMode connectMode;
|
||||||
QString tcpHost;
|
QString tcpHost;
|
||||||
quint64 tcpPort;
|
quint64 tcpPort;
|
||||||
@@ -73,7 +70,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
|
QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
|
||||||
QObject(parent), d(new QmlProfilerClientManagerPrivate(this))
|
QObject(parent), d(new QmlProfilerClientManagerPrivate)
|
||||||
{
|
{
|
||||||
setObjectName(QLatin1String("QML Profiler Connections"));
|
setObjectName(QLatin1String("QML Profiler Connections"));
|
||||||
|
|
||||||
@@ -97,6 +94,7 @@ QmlProfilerClientManager::~QmlProfilerClientManager()
|
|||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// Interface
|
// Interface
|
||||||
void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
|
void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
|
||||||
|
@@ -30,18 +30,19 @@
|
|||||||
#ifndef QMLPROFILERCLIENTMANAGER_H
|
#ifndef QMLPROFILERCLIENTMANAGER_H
|
||||||
#define QMLPROFILERCLIENTMANAGER_H
|
#define QMLPROFILERCLIENTMANAGER_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include "qmlprofilerstatemanager.h"
|
#include "qmlprofilerstatemanager.h"
|
||||||
#include <qmldebug/qmlprofilereventlocation.h>
|
#include <qmldebug/qmlprofilereventlocation.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlProfilerClientManager : public QObject
|
class QmlProfilerClientManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QmlProfilerClientManager(QObject *parent = 0);
|
explicit QmlProfilerClientManager(QObject *parent = 0);
|
||||||
~QmlProfilerClientManager();
|
~QmlProfilerClientManager();
|
||||||
@@ -84,9 +85,6 @@ private slots:
|
|||||||
void serverRecordingChanged();
|
void serverRecordingChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QmlProfilerClientManagerPrivate;
|
|
||||||
QmlProfilerClientManagerPrivate *d;
|
|
||||||
|
|
||||||
void connectToClient();
|
void connectToClient();
|
||||||
|
|
||||||
void enableServices();
|
void enableServices();
|
||||||
@@ -94,9 +92,12 @@ private:
|
|||||||
void disconnectClientSignals();
|
void disconnectClientSignals();
|
||||||
|
|
||||||
void stopClientsRecording();
|
void stopClientsRecording();
|
||||||
|
|
||||||
|
class QmlProfilerClientManagerPrivate;
|
||||||
|
QmlProfilerClientManagerPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Internal
|
||||||
}
|
} // namespace QmlProfiler
|
||||||
|
|
||||||
#endif // QMLPROFILERCLIENTMANAGER_H
|
#endif // QMLPROFILERCLIENTMANAGER_H
|
||||||
|
@@ -38,7 +38,8 @@
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
inline QString stringForState(int state) {
|
static QString stringForState(int state)
|
||||||
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
|
case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
|
||||||
case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting");
|
case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting");
|
||||||
@@ -53,92 +54,79 @@ inline QString stringForState(int state) {
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
class QmlProfilerStateManager::QmlProfilerStateManagerPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QmlProfilerStateManagerPrivate(QmlProfilerStateManager *qq) : q(qq) {}
|
|
||||||
~QmlProfilerStateManagerPrivate() {}
|
|
||||||
|
|
||||||
QmlProfilerStateManager *q;
|
|
||||||
|
|
||||||
QmlProfilerStateManager::QmlProfilerState m_currentState;
|
|
||||||
bool m_clientRecording;
|
|
||||||
bool m_serverRecording;
|
|
||||||
};
|
|
||||||
QmlProfilerStateManager::QmlProfilerStateManager(QObject *parent) :
|
QmlProfilerStateManager::QmlProfilerStateManager(QObject *parent) :
|
||||||
QObject(parent),d(new QmlProfilerStateManagerPrivate(this))
|
QObject(parent)
|
||||||
{
|
{
|
||||||
d->m_currentState = Idle;
|
m_currentState = Idle;
|
||||||
d->m_clientRecording = true;
|
m_clientRecording = true;
|
||||||
d->m_serverRecording = false;
|
m_serverRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerStateManager::~QmlProfilerStateManager()
|
QmlProfilerStateManager::~QmlProfilerStateManager()
|
||||||
{
|
{
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerStateManager::QmlProfilerState QmlProfilerStateManager::currentState()
|
QmlProfilerStateManager::QmlProfilerState QmlProfilerStateManager::currentState() const
|
||||||
{
|
{
|
||||||
return d->m_currentState;
|
return m_currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProfilerStateManager::clientRecording()
|
bool QmlProfilerStateManager::clientRecording() const
|
||||||
{
|
{
|
||||||
return d->m_clientRecording;
|
return m_clientRecording;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProfilerStateManager::serverRecording()
|
bool QmlProfilerStateManager::serverRecording() const
|
||||||
{
|
{
|
||||||
return d->m_serverRecording;
|
return m_serverRecording;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlProfilerStateManager::currentStateAsString()
|
QString QmlProfilerStateManager::currentStateAsString() const
|
||||||
{
|
{
|
||||||
return stringForState(d->m_currentState);
|
return stringForState(m_currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG_PROFILERSTATE_
|
#ifdef _DEBUG_PROFILERSTATE_
|
||||||
qDebug() << "Profiler state change request from" << stringForState(d->m_currentState) << "to" << stringForState(newState);
|
qDebug() << "Profiler state change request from" << currentStateAsString() << "to" << stringForState(newState);
|
||||||
#endif
|
#endif
|
||||||
QTC_ASSERT(d->m_currentState != newState, /**/);
|
QTC_ASSERT(m_currentState != newState, /**/);
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case Idle:
|
case Idle:
|
||||||
QTC_ASSERT(d->m_currentState == AppStarting ||
|
QTC_ASSERT(m_currentState == AppStarting ||
|
||||||
d->m_currentState == AppStopped ||
|
m_currentState == AppStopped ||
|
||||||
d->m_currentState == AppKilled,
|
m_currentState == AppKilled,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppStarting:
|
case AppStarting:
|
||||||
QTC_ASSERT(d->m_currentState == Idle,
|
QTC_ASSERT(m_currentState == Idle,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppRunning:
|
case AppRunning:
|
||||||
QTC_ASSERT(d->m_currentState == AppStarting,
|
QTC_ASSERT(m_currentState == AppStarting,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppStopRequested:
|
case AppStopRequested:
|
||||||
QTC_ASSERT(d->m_currentState == AppRunning,
|
QTC_ASSERT(m_currentState == AppRunning,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppReadyToStop:
|
case AppReadyToStop:
|
||||||
QTC_ASSERT(d->m_currentState == AppStopRequested,
|
QTC_ASSERT(m_currentState == AppStopRequested,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppStopped:
|
case AppStopped:
|
||||||
QTC_ASSERT(d->m_currentState == AppReadyToStop ||
|
QTC_ASSERT(m_currentState == AppReadyToStop ||
|
||||||
d->m_currentState == AppDying,
|
m_currentState == AppDying,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppDying:
|
case AppDying:
|
||||||
QTC_ASSERT(d->m_currentState == AppRunning,
|
QTC_ASSERT(m_currentState == AppRunning,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
case AppKilled:
|
case AppKilled:
|
||||||
QTC_ASSERT(d->m_currentState == AppDying,
|
QTC_ASSERT(m_currentState == AppDying,
|
||||||
qDebug() << "from" << stringForState(d->m_currentState));
|
qDebug() << "from" << currentStateAsString());
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
@@ -147,17 +135,17 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_currentState = newState;
|
m_currentState = newState;
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerStateManager::setClientRecording(bool recording)
|
void QmlProfilerStateManager::setClientRecording(bool recording)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG_PROFILERSTATE_
|
#ifdef _DEBUG_PROFILERSTATE_
|
||||||
qDebug() << "Setting client recording flag from" << d->m_serverRecording << "to" << recording;
|
qDebug() << "Setting client recording flag from" << m_serverRecording << "to" << recording;
|
||||||
#endif
|
#endif
|
||||||
if (d->m_clientRecording != recording) {
|
if (m_clientRecording != recording) {
|
||||||
d->m_clientRecording = recording;
|
m_clientRecording = recording;
|
||||||
emit clientRecordingChanged();
|
emit clientRecordingChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,13 +153,13 @@ void QmlProfilerStateManager::setClientRecording(bool recording)
|
|||||||
void QmlProfilerStateManager::setServerRecording(bool recording)
|
void QmlProfilerStateManager::setServerRecording(bool recording)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG_PROFILERSTATE_
|
#ifdef _DEBUG_PROFILERSTATE_
|
||||||
qDebug() << "Setting server recording flag from" << d->m_serverRecording << "to" << recording;
|
qDebug() << "Setting server recording flag from" << m_serverRecording << "to" << recording;
|
||||||
#endif
|
#endif
|
||||||
if (d->m_serverRecording != recording) {
|
if (m_serverRecording != recording) {
|
||||||
d->m_serverRecording = recording;
|
m_serverRecording = recording;
|
||||||
emit serverRecordingChanged();
|
emit serverRecordingChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace Internal
|
||||||
}
|
} // namespace QmlProfiler
|
||||||
|
@@ -38,6 +38,7 @@ namespace Internal {
|
|||||||
class QmlProfilerStateManager : public QObject
|
class QmlProfilerStateManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum QmlProfilerState {
|
enum QmlProfilerState {
|
||||||
Idle,
|
Idle,
|
||||||
@@ -53,11 +54,11 @@ public:
|
|||||||
explicit QmlProfilerStateManager(QObject *parent = 0);
|
explicit QmlProfilerStateManager(QObject *parent = 0);
|
||||||
~QmlProfilerStateManager();
|
~QmlProfilerStateManager();
|
||||||
|
|
||||||
QmlProfilerState currentState();
|
QmlProfilerState currentState() const;
|
||||||
bool clientRecording();
|
bool clientRecording() const;
|
||||||
bool serverRecording();
|
bool serverRecording() const;
|
||||||
|
|
||||||
QString currentStateAsString();
|
QString currentStateAsString() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged();
|
void stateChanged();
|
||||||
@@ -70,11 +71,12 @@ public slots:
|
|||||||
void setServerRecording(bool recording);
|
void setServerRecording(bool recording);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QmlProfilerStateManagerPrivate;
|
QmlProfilerStateManager::QmlProfilerState m_currentState;
|
||||||
QmlProfilerStateManagerPrivate *d;
|
bool m_clientRecording;
|
||||||
|
bool m_serverRecording;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Internal
|
||||||
}
|
} // namespace QmlProfiler
|
||||||
|
|
||||||
#endif // QMLPROFILERSTATEMANAGER_H
|
#endif // QMLPROFILERSTATEMANAGER_H
|
||||||
|
Reference in New Issue
Block a user