diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-08-05 11:12:27 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2011-08-05 12:17:30 +0200 |
commit | 687a60065a26ab2b38077dfb77c3b88f556460d1 (patch) | |
tree | da89b9dff633ffbe158918ea491b3ce1f25663f3 /src/plugins/qmlprofiler | |
parent | 4cd119a985dcaf9b2744b4db7a4fc2fdee5a306a (diff) | |
download | qt-creator-687a60065a26ab2b38077dfb77c3b88f556460d1.tar.gz |
QmlJSDebugClient: Move QmlProfilerTraceClient into library
Change-Id: I1c0821778a3350ec55741b45680fca2cb1fed3aa
Reviewed-on: http://codereview.qt.nokia.com/2680
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofiler.pro | 3 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilereventtypes.h | 52 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilereventview.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilereventview.h | 6 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceclient.cpp | 166 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceclient.h | 122 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/tracewindow.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/tracewindow.h | 4 |
8 files changed, 11 insertions, 350 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 0b3ad3f024..107acdcfc5 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -26,7 +26,6 @@ SOURCES += \ localqmlprofilerrunner.cpp \ codaqmlprofilerrunner.cpp \ remotelinuxqmlprofilerrunner.cpp \ - qmlprofilertraceclient.cpp \ qmlprofilereventview.cpp \ qmlprofilerruncontrolfactory.cpp @@ -43,9 +42,7 @@ HEADERS += \ localqmlprofilerrunner.h \ codaqmlprofilerrunner.h \ remotelinuxqmlprofilerrunner.h \ - qmlprofilertraceclient.h \ qmlprofilereventview.h \ - qmlprofilereventtypes.h \ qmlprofilerruncontrolfactory.h RESOURCES += \ diff --git a/src/plugins/qmlprofiler/qmlprofilereventtypes.h b/src/plugins/qmlprofiler/qmlprofilereventtypes.h deleted file mode 100644 index 1739f90aef..0000000000 --- a/src/plugins/qmlprofiler/qmlprofilereventtypes.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QMLPROFILEREVENTTYPES_H -#define QMLPROFILEREVENTTYPES_H - -namespace QmlProfiler { -namespace Internal { - -enum QmlEventType { - Painting, - Compiling, - Creating, - Binding, - HandlingSignal, - - MaximumQmlEventType -}; - -} -} - -#endif //QMLPROFILEREVENTTYPES_H diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index 62c990716a..aa97693774 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -38,6 +38,8 @@ #include <QtGui/QHeaderView> #include <QtGui/QStandardItemModel> +using namespace QmlJsDebugClient; + namespace QmlProfiler { namespace Internal { diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index 857c5058ae..a04b6d3128 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -34,7 +34,7 @@ #define QMLPROFILEREVENTVIEW_H #include <QTreeView> -#include "qmlprofilereventtypes.h" +#include <qmljsdebugclient/qmlprofilereventtypes.h> namespace QmlProfiler { namespace Internal { @@ -42,7 +42,7 @@ namespace Internal { struct QmlEventData { QmlEventData() : displayname(0) , filename(0) , location(0) , details(0), - line(0), eventType(MaximumQmlEventType), level(-1), parentList(0), childrenList(0) {} + line(0), eventType(QmlJsDebugClient::MaximumQmlEventType), level(-1), parentList(0), childrenList(0) {} ~QmlEventData() { delete displayname; delete filename; @@ -55,7 +55,7 @@ struct QmlEventData QString *location; QString *details; int line; - QmlEventType eventType; + QmlJsDebugClient::QmlEventType eventType; qint64 level; QList< QmlEventData *> *parentList; QList< QmlEventData *> *childrenList; diff --git a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp b/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp deleted file mode 100644 index 9e663d7c21..0000000000 --- a/src/plugins/qmlprofiler/qmlprofilertraceclient.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "qmlprofilertraceclient.h" - -using namespace QmlProfiler::Internal; -using namespace QmlJsDebugClient; - -static const int GAP_TIME = 150; - -QmlProfilerTraceClient::QmlProfilerTraceClient(QDeclarativeDebugConnection *client) - : QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client), - m_inProgressRanges(0), m_maximumTime(0), m_recording(false), m_nestingLevel(0) -{ - ::memset(m_rangeCount, 0, MaximumQmlEventType * sizeof(int)); - ::memset(m_nestingInType, 0, MaximumQmlEventType * sizeof(int)); -} - -void QmlProfilerTraceClient::clearView() -{ - ::memset(m_rangeCount, 0, MaximumQmlEventType * sizeof(int)); - ::memset(m_nestingInType, 0, MaximumQmlEventType * sizeof(int)); - m_nestingLevel = 0; - emit clear(); -} - -void QmlProfilerTraceClient::setRecording(bool v) -{ - if (v == m_recording) - return; - - if (status() == Enabled) { - QByteArray ba; - QDataStream stream(&ba, QIODevice::WriteOnly); - stream << v; - sendMessage(ba); - } - - m_recording = v; - emit recordingChanged(v); -} - -void QmlProfilerTraceClient::statusChanged(Status status) -{ - if (status == Enabled) { - m_recording = !m_recording; - setRecording(!m_recording); - emit enabled(); - } -} - -void QmlProfilerTraceClient::messageReceived(const QByteArray &data) -{ - QByteArray rwData = data; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - qint64 time; - int messageType; - - stream >> time >> messageType; - -// qDebug() << __FUNCTION__ << messageType; - - if (messageType >= MaximumMessage) - return; - - if (time > (m_maximumTime + GAP_TIME) && 0 == m_inProgressRanges) - emit gap(time); - - if (messageType == Event) { - int event; - stream >> event; - - if (event < MaximumEventType) { - emit this->event((EventType)event, time); - m_maximumTime = qMax(time, m_maximumTime); - } - } else if (messageType == Complete) { - emit complete(); - } else { - int range; - stream >> range; - - if (range >= MaximumQmlEventType) - return; - - if (messageType == RangeStart) { - m_rangeStartTimes[range].push(time); - m_inProgressRanges |= (static_cast<qint64>(1) << range); - ++m_rangeCount[range]; - ++m_nestingLevel; - ++m_nestingInType[range]; - } else if (messageType == RangeData) { - QString data; - stream >> data; - - int count = m_rangeCount[range]; - if (count > 0) { - while (m_rangeDatas[range].count() < count) - m_rangeDatas[range].push(QStringList()); - m_rangeDatas[range][count-1] << data; - } - - } else if (messageType == RangeLocation) { - QString fileName; - int line; - stream >> fileName >> line; - - if (m_rangeCount[range] > 0) { - m_rangeLocations[range].push(Location(fileName, line)); - } - } else { - if (m_rangeCount[range] > 0) { - --m_rangeCount[range]; - if (m_inProgressRanges & (static_cast<qint64>(1) << range)) - m_inProgressRanges &= ~(static_cast<qint64>(1) << range); - - m_maximumTime = qMax(time, m_maximumTime); - QStringList data = m_rangeDatas[range].count() ? m_rangeDatas[range].pop() : QStringList(); - Location location = m_rangeLocations[range].count() ? m_rangeLocations[range].pop() : Location(); - - qint64 startTime = m_rangeStartTimes[range].pop(); - emit this->range((QmlEventType)range, m_nestingLevel, m_nestingInType[range], startTime, - time - startTime, data, location.fileName, location.line); - --m_nestingLevel; - --m_nestingInType[range]; - if (m_rangeCount[range] == 0) { - int count = m_rangeDatas[range].count() + - m_rangeStartTimes[range].count() + - m_rangeLocations[range].count(); - if (count != 0) - qWarning() << "incorrectly nested data"; - } - } - } - } -} diff --git a/src/plugins/qmlprofiler/qmlprofilertraceclient.h b/src/plugins/qmlprofiler/qmlprofilertraceclient.h deleted file mode 100644 index 827391143a..0000000000 --- a/src/plugins/qmlprofiler/qmlprofilertraceclient.h +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QMLPROFILERTRACECLIENT_H -#define QMLPROFILERTRACECLIENT_H - -#include <qmljsdebugclient/qdeclarativedebugclient.h> -#include <QtCore/QStack> -#include <QtCore/QStringList> - -#include "qmlprofilereventtypes.h" - -namespace QmlProfiler { -namespace Internal { - -struct Location -{ - Location() : line(-1) {} - Location(const QString &file, int lineNumber) : fileName(file), line(lineNumber) {} - QString fileName; - int line; -}; - -class QmlProfilerTraceClient : public QmlJsDebugClient::QDeclarativeDebugClient -{ - Q_OBJECT - Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged) - - // don't hide by signal - using QObject::event; - -public: - QmlProfilerTraceClient(QmlJsDebugClient::QDeclarativeDebugConnection *client); - - enum EventType { - FramePaint, - Mouse, - Key, - - MaximumEventType - }; - - enum Message { - Event, - RangeStart, - RangeData, - RangeLocation, - RangeEnd, - Complete, - - MaximumMessage - }; - - bool isRecording() const { return m_recording; } - -public slots: - void setRecording(bool); - void clearView(); - -signals: - void complete(); - void gap(qint64); - void event(int event, qint64 time); - void range(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, - const QStringList &data, const QString &fileName, int line); - - void sample(int, int, int, bool); - - void recordingChanged(bool arg); - - void enabled(); - void clear(); - -protected: - virtual void statusChanged(Status); - virtual void messageReceived(const QByteArray &); - -private: - qint64 m_inProgressRanges; - QStack<qint64> m_rangeStartTimes[MaximumQmlEventType]; - QStack<QStringList> m_rangeDatas[MaximumQmlEventType]; - QStack<Location> m_rangeLocations[MaximumQmlEventType]; - int m_rangeCount[MaximumQmlEventType]; - qint64 m_maximumTime; - bool m_recording; - int m_nestingLevel; - int m_nestingInType[MaximumQmlEventType]; -}; - -} // namespace Internal -} // namespace QmlProfiler - -#endif // QMLPROFILERTRACECLIENT_H diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index 380a54d50f..f3ab9722c1 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -33,9 +33,9 @@ #include "tracewindow.h" #include "qmlprofilerplugin.h" -#include "qmlprofilertraceclient.h" #include <qmljsdebugclient/qdeclarativedebugclient.h> +#include <qmljsdebugclient/qmlprofilertraceclient.h> #include <utils/styledbar.h> #include <QtDeclarative/QDeclarativeView> @@ -44,6 +44,8 @@ #include <QtGui/QToolButton> #include <QtGui/QGraphicsObject> +using namespace QmlJsDebugClient; + namespace QmlProfiler { namespace Internal { @@ -112,7 +114,7 @@ TraceWindow::~TraceWindow() delete m_plugin.data(); } -void TraceWindow::reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn) +void TraceWindow::reset(QDeclarativeDebugConnection *conn) { if (m_plugin) disconnect(m_plugin.data(), SIGNAL(complete()), this, SIGNAL(viewUpdated())); diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index ffd414d9ca..5629f977f0 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -33,7 +33,7 @@ #ifndef TRACEWINDOW_H #define TRACEWINDOW_H -#include "qmlprofilertraceclient.h" +#include <qmljsdebugclient/qmlprofilertraceclient.h> #include <QtCore/QPointer> #include <QtGui/QWidget> @@ -79,7 +79,7 @@ signals: void enableToolbar(bool); private: - QWeakPointer<QmlProfilerTraceClient> m_plugin; + QWeakPointer<QmlJsDebugClient::QmlProfilerTraceClient> m_plugin; QSize m_sizeHint; QDeclarativeView *m_view; |