aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-09-15 15:14:40 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-10-15 08:23:29 +0000
commitd56286283dc41d1e97502f48ded754c059951060 (patch)
tree42285d61fb81cc73f403d41e16a9aaf3a40bfe46
parent2f03049d4cabfac822bcf6b5886b078d70064968 (diff)
qmlprofiler: Simplify QmlProfilerClient
We only need one class for it now. Change-Id: Iea2715993c0ce168a3ceeecbb694f1ad3585da68 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp24
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h3
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.cpp54
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h35
4 files changed, 32 insertions, 84 deletions
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 74356c21a3..010e82ce5a 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -93,7 +93,8 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
connect(&m_connection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged(QAbstractSocket::SocketState)));
connect(&m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
- connect(&m_qmlProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled()));
+ connect(&m_qmlProfilerClient, SIGNAL(enabledChanged(bool)),
+ this, SLOT(traceClientEnabledChanged(bool)));
connect(&m_qmlProfilerClient, SIGNAL(range(QQmlProfilerDefinitions::RangeType,QQmlProfilerDefinitions::BindingType,qint64,qint64,QStringList,QmlEventLocation)),
&m_profilerData, SLOT(addQmlEvent(QQmlProfilerDefinitions::RangeType,QQmlProfilerDefinitions::BindingType,qint64,qint64,QStringList,QmlEventLocation)));
connect(&m_qmlProfilerClient, SIGNAL(traceFinished(qint64)), &m_profilerData, SLOT(setTraceEndTime(qint64)));
@@ -554,21 +555,14 @@ void QmlProfilerApplication::processFinished()
exit(exitCode);
}
-void QmlProfilerApplication::traceClientEnabled()
+void QmlProfilerApplication::traceClientEnabledChanged(bool enabled)
{
- logStatus("Trace client is attached.");
- // blocked server is waiting for recording message from both clients
- // once the last one is connected, both messages should be sent
- m_qmlProfilerClient.sendRecordingStatus(m_recording);
-}
-
-void QmlProfilerApplication::profilerClientEnabled()
-{
- logStatus("Profiler client is attached.");
-
- // blocked server is waiting for recording message from both clients
- // once the last one is connected, both messages should be sent
- m_qmlProfilerClient.sendRecordingStatus(m_recording);
+ if (enabled) {
+ logStatus("Trace client is attached.");
+ // blocked server is waiting for recording message from both clients
+ // once the last one is connected, both messages should be sent
+ m_qmlProfilerClient.sendRecordingStatus(m_recording);
+ }
}
void QmlProfilerApplication::traceFinished()
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index bd3e51aa03..1f06108673 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -78,8 +78,7 @@ private slots:
void processHasOutput();
void processFinished();
- void traceClientEnabled();
- void profilerClientEnabled();
+ void traceClientEnabledChanged(bool enabled);
void traceFinished();
void prompt(const QString &line = QString(), bool ready = true);
diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp
index ff723381bc..bd7b98379f 100644
--- a/tools/qmlprofiler/qmlprofilerclient.cpp
+++ b/tools/qmlprofiler/qmlprofilerclient.cpp
@@ -39,42 +39,11 @@
#include <limits>
-ProfilerClient::ProfilerClient(const QString &clientName,
- QQmlDebugConnection *client)
- : QQmlDebugClient(clientName, client),
- m_enabled(false)
-{
-}
-
-ProfilerClient::~ProfilerClient()
-{
-}
-
-void ProfilerClient::clearData()
-{
- emit cleared();
-}
-
-bool ProfilerClient::isEnabled() const
-{
- return m_enabled;
-}
-
-void ProfilerClient::stateChanged(State status)
-{
- if ((m_enabled && status != Enabled) ||
- (!m_enabled && status == Enabled))
- emit enabledChanged();
-
- m_enabled = status == Enabled;
-
-}
-
class QmlProfilerClientPrivate
{
public:
QmlProfilerClientPrivate()
- : inProgressRanges(0) , features(std::numeric_limits<quint64>::max())
+ : inProgressRanges(0) , features(std::numeric_limits<quint64>::max()), enabled(false)
{
::memset(rangeCount, 0, QQmlProfilerDefinitions::MaximumRangeType * sizeof(int));
}
@@ -87,11 +56,11 @@ public:
int rangeCount[QQmlProfilerDefinitions::MaximumRangeType];
quint64 features;
+ bool enabled;
};
-QmlProfilerClient::QmlProfilerClient(
- QQmlDebugConnection *client)
- : ProfilerClient(QStringLiteral("CanvasFrameRate"), client),
+QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *client)
+ : QQmlDebugClient(QStringLiteral("CanvasFrameRate"), client),
d(new QmlProfilerClientPrivate)
{
}
@@ -108,9 +77,12 @@ void QmlProfilerClient::setFeatures(quint64 features)
void QmlProfilerClient::clearData()
{
- ::memset(d->rangeCount, 0, QQmlProfilerDefinitions::MaximumRangeType * sizeof(int));
+ for (int i = 0; i < QQmlProfilerDefinitions::MaximumRangeType; ++i) {
+ d->rangeCount[i] = 0;
+ d->rangeDatas[i].clear();
+ d->rangeLocations[i].clear();
+ }
d->bindingTypes.clear();
- ProfilerClient::clearData();
}
void QmlProfilerClient::sendRecordingStatus(bool record)
@@ -142,6 +114,14 @@ inline QQmlProfilerDefinitions::ProfileFeature featureFromRangeType(
}
}
+void QmlProfilerClient::stateChanged(State state)
+{
+ if ((d->enabled && state != Enabled) || (!d->enabled && state == Enabled)) {
+ d->enabled = (state == Enabled);
+ emit enabledChanged(d->enabled);
+ }
+}
+
void QmlProfilerClient::messageReceived(const QByteArray &data)
{
QByteArray rwData = data;
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index 72423ea676..b4bf97fdf3 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -38,35 +38,7 @@
#include "qmlprofilereventlocation.h"
#include <QtQml/private/qqmlprofilerdefinitions_p.h>
-class ProfilerClientPrivate;
-class ProfilerClient : public QQmlDebugClient
-{
- Q_OBJECT
-
- Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
-public:
- ProfilerClient(const QString &clientName,
- QQmlDebugConnection *client);
- ~ProfilerClient();
-
- bool isEnabled() const;
-
-public slots:
- virtual void clearData();
-
-signals:
- void complete();
- void enabledChanged();
- void cleared();
-
-protected:
- virtual void stateChanged(State);
-
-protected:
- bool m_enabled;
-};
-
-class QmlProfilerClient : public ProfilerClient
+class QmlProfilerClient : public QQmlDebugClient
{
Q_OBJECT
@@ -75,9 +47,9 @@ public:
~QmlProfilerClient();
void setFeatures(quint64 features);
+ void clearData();
public slots:
- void clearData();
void sendRecordingStatus(bool record);
signals:
@@ -96,8 +68,11 @@ signals:
const QmlEventLocation &location, int width, int height, int refCount);
void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount);
void inputEvent(QQmlProfilerDefinitions::EventType, qint64 time);
+ void complete();
+ void enabledChanged(bool enabled);
protected:
+ virtual void stateChanged(State state);
virtual void messageReceived(const QByteArray &);
private: