2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-02-24 10:47:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include "qmlprofilerclientmanager.h"
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
#include "qmlprofilerplugin.h"
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
#include <qmldebug/qmldebugclient.h>
|
|
|
|
|
#include <qmldebug/qmlprofilertraceclient.h>
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2012-09-24 13:48:18 +02:00
|
|
|
#include <QPointer>
|
2012-02-24 10:47:17 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
#include "qmlprofilermodelmanager.h"
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
using namespace QmlDebug;
|
2012-02-24 10:47:17 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2013-08-29 19:04:29 +02:00
|
|
|
class QmlProfilerClientManager::QmlProfilerClientManagerPrivate
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
public:
|
2013-08-29 19:04:29 +02:00
|
|
|
QmlProfilerStateManager *profilerState;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebugConnection *connection;
|
2012-09-24 13:48:18 +02:00
|
|
|
QPointer<QmlProfilerTraceClient> qmlclientplugin;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
QTimer connectionTimer;
|
|
|
|
|
int connectionAttempts;
|
|
|
|
|
|
|
|
|
|
QString tcpHost;
|
|
|
|
|
quint64 tcpPort;
|
|
|
|
|
QString sysroot;
|
2015-08-28 12:50:46 +02:00
|
|
|
quint32 flushInterval;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
bool qmlDataReady;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
QmlProfilerModelManager *modelManager;
|
2012-02-24 10:47:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
|
2013-08-29 19:04:29 +02:00
|
|
|
QObject(parent), d(new QmlProfilerClientManagerPrivate)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QML Profiler Connections"));
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
d->profilerState = 0;
|
|
|
|
|
|
|
|
|
|
d->connection = 0;
|
|
|
|
|
d->connectionAttempts = 0;
|
|
|
|
|
d->qmlDataReady = false;
|
2015-08-28 12:50:46 +02:00
|
|
|
d->flushInterval = 0;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelManager = 0;
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
d->connectionTimer.setInterval(200);
|
|
|
|
|
connect(&d->connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerClientManager::~QmlProfilerClientManager()
|
|
|
|
|
{
|
|
|
|
|
delete d->connection;
|
|
|
|
|
delete d->qmlclientplugin.data();
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
2013-07-30 18:35:51 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerClientManager::setModelManager(QmlProfilerModelManager *m)
|
|
|
|
|
{
|
2013-11-11 22:20:47 +02:00
|
|
|
if (d->modelManager)
|
2013-08-08 13:28:08 +02:00
|
|
|
disconnect(this,SIGNAL(dataReadyForProcessing()), d->modelManager, SLOT(complete()));
|
|
|
|
|
d->modelManager = m;
|
2013-11-11 22:20:47 +02:00
|
|
|
if (d->modelManager)
|
2013-08-08 13:28:08 +02:00
|
|
|
connect(this,SIGNAL(dataReadyForProcessing()), d->modelManager, SLOT(complete()));
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
void QmlProfilerClientManager::setFlushInterval(quint32 flushInterval)
|
|
|
|
|
{
|
|
|
|
|
d->flushInterval = flushInterval;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
|
|
|
|
|
{
|
|
|
|
|
d->tcpHost = host;
|
|
|
|
|
d->tcpPort = port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::clearBufferedData()
|
|
|
|
|
{
|
|
|
|
|
if (d->qmlclientplugin)
|
|
|
|
|
d->qmlclientplugin.data()->clearData();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-26 16:20:09 +02:00
|
|
|
void QmlProfilerClientManager::discardPendingData()
|
|
|
|
|
{
|
|
|
|
|
clearBufferedData();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerClientManager::connectClient(quint16 port)
|
|
|
|
|
{
|
|
|
|
|
if (d->connection)
|
|
|
|
|
delete d->connection;
|
2012-04-18 12:06:10 +02:00
|
|
|
d->connection = new QmlDebugConnection;
|
2012-02-24 10:47:17 +01:00
|
|
|
enableServices();
|
2014-05-05 17:18:11 +02:00
|
|
|
connect(d->connection, SIGNAL(stateMessage(QString)), this, SLOT(logState(QString)));
|
|
|
|
|
connect(d->connection, SIGNAL(errorMessage(QString)), this, SLOT(logState(QString)));
|
|
|
|
|
connect(d->connection, SIGNAL(opened()), this, SLOT(qmlDebugConnectionOpened()));
|
|
|
|
|
connect(d->connection, SIGNAL(closed()), this, SLOT(qmlDebugConnectionClosed()));
|
2012-02-24 10:47:17 +01:00
|
|
|
d->connectionTimer.start();
|
|
|
|
|
d->tcpPort = port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::enableServices()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->profilerState, return);
|
|
|
|
|
|
|
|
|
|
disconnectClientSignals();
|
|
|
|
|
d->profilerState->setServerRecording(false); // false by default (will be set to true when connected)
|
|
|
|
|
delete d->qmlclientplugin.data();
|
2015-06-30 15:55:33 +02:00
|
|
|
d->profilerState->setRecordedFeatures(0);
|
2014-09-09 18:22:58 +02:00
|
|
|
d->qmlclientplugin = new QmlProfilerTraceClient(d->connection,
|
2015-06-30 15:55:33 +02:00
|
|
|
d->profilerState->requestedFeatures());
|
2015-08-28 12:50:46 +02:00
|
|
|
d->qmlclientplugin->setFlushInterval(d->flushInterval);
|
2012-02-24 10:47:17 +01:00
|
|
|
connectClientSignals();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::connectClientSignals()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->profilerState, return);
|
|
|
|
|
if (d->qmlclientplugin) {
|
2014-04-03 12:33:14 +02:00
|
|
|
connect(d->qmlclientplugin.data(), SIGNAL(complete(qint64)),
|
|
|
|
|
this, SLOT(qmlComplete(qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(d->qmlclientplugin.data(),
|
2014-06-03 16:57:32 +02:00
|
|
|
SIGNAL(rangedEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
|
2014-06-13 16:33:30 +02:00
|
|
|
QString,QmlDebug::QmlEventLocation,qint64,qint64,qint64,
|
2014-06-03 16:57:32 +02:00
|
|
|
qint64,qint64)),
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelManager,
|
2014-06-03 16:57:32 +02:00
|
|
|
SLOT(addQmlEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
|
2014-06-13 16:33:30 +02:00
|
|
|
QString,QmlDebug::QmlEventLocation,qint64,qint64,qint64,qint64,
|
2014-06-03 16:57:32 +02:00
|
|
|
qint64)));
|
2014-03-12 17:20:52 +01:00
|
|
|
connect(d->qmlclientplugin.data(), SIGNAL(traceFinished(qint64,QList<int>)),
|
|
|
|
|
d->modelManager->traceTime(), SLOT(increaseEndTime(qint64)));
|
|
|
|
|
connect(d->qmlclientplugin.data(), SIGNAL(traceStarted(qint64,QList<int>)),
|
|
|
|
|
d->modelManager->traceTime(), SLOT(decreaseStartTime(qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(d->qmlclientplugin.data(), SIGNAL(enabledChanged()),
|
|
|
|
|
d->qmlclientplugin.data(), SLOT(sendRecordingStatus()));
|
|
|
|
|
connect(d->qmlclientplugin.data(), SIGNAL(recordingChanged(bool)),
|
|
|
|
|
d->profilerState, SLOT(setServerRecording(bool)));
|
2015-06-30 15:55:33 +02:00
|
|
|
connect(d->profilerState, &QmlProfilerStateManager::requestedFeaturesChanged,
|
|
|
|
|
d->qmlclientplugin.data(), &QmlProfilerTraceClient::setRequestedFeatures);
|
|
|
|
|
connect(d->qmlclientplugin.data(), &QmlProfilerTraceClient::recordedFeaturesChanged,
|
|
|
|
|
d->profilerState, &QmlProfilerStateManager::setRecordedFeatures);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::disconnectClientSignals()
|
|
|
|
|
{
|
|
|
|
|
if (d->qmlclientplugin) {
|
2014-05-08 14:37:29 +02:00
|
|
|
disconnect(d->qmlclientplugin.data(), SIGNAL(complete(qint64)),
|
|
|
|
|
this, SLOT(qmlComplete(qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
disconnect(d->qmlclientplugin.data(),
|
2013-08-08 13:28:08 +02:00
|
|
|
SIGNAL(rangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
|
|
|
|
|
qint64,qint64,qint64,qint64,qint64)),
|
|
|
|
|
d->modelManager,
|
|
|
|
|
SLOT(addQmlEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
|
|
|
|
|
qint64,qint64,qint64,qint64,qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
disconnect(d->qmlclientplugin.data(), SIGNAL(traceFinished(qint64)),
|
2014-10-14 16:44:45 +02:00
|
|
|
d->modelManager->traceTime(), SLOT(increaseEndTime(qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
disconnect(d->qmlclientplugin.data(), SIGNAL(traceStarted(qint64)),
|
2014-10-14 16:44:45 +02:00
|
|
|
d->modelManager->traceTime(), SLOT(decreaseStartTime(qint64)));
|
2012-02-24 10:47:17 +01:00
|
|
|
disconnect(d->qmlclientplugin.data(), SIGNAL(enabledChanged()),
|
|
|
|
|
d->qmlclientplugin.data(), SLOT(sendRecordingStatus()));
|
|
|
|
|
// fixme: this should be unified for both clients
|
|
|
|
|
disconnect(d->qmlclientplugin.data(), SIGNAL(recordingChanged(bool)),
|
|
|
|
|
d->profilerState, SLOT(setServerRecording(bool)));
|
2015-06-30 15:55:33 +02:00
|
|
|
disconnect(d->profilerState, &QmlProfilerStateManager::requestedFeaturesChanged,
|
|
|
|
|
d->qmlclientplugin.data(), &QmlProfilerTraceClient::setRequestedFeatures);
|
|
|
|
|
disconnect(d->qmlclientplugin.data(), &QmlProfilerTraceClient::recordedFeaturesChanged,
|
|
|
|
|
d->profilerState, &QmlProfilerStateManager::setRecordedFeatures);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::connectToClient()
|
|
|
|
|
{
|
2015-07-06 14:33:49 +02:00
|
|
|
if (!d->connection || d->connection->isOpen() || d->connection->isConnecting())
|
2012-02-24 10:47:17 +01:00
|
|
|
return;
|
|
|
|
|
|
2012-08-22 13:27:25 +02:00
|
|
|
d->connection->connectToHost(d->tcpHost, d->tcpPort);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2012-05-11 17:19:15 +02:00
|
|
|
bool QmlProfilerClientManager::isConnected() const
|
|
|
|
|
{
|
2014-05-05 18:01:02 +02:00
|
|
|
return d->connection && d->connection->isOpen();
|
2012-05-11 17:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerClientManager::disconnectClient()
|
|
|
|
|
{
|
|
|
|
|
// this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow
|
2013-10-07 13:34:40 +02:00
|
|
|
// function to complete before deleting object
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->connection) {
|
|
|
|
|
d->connection->deleteLater();
|
|
|
|
|
d->connection = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::tryToConnect()
|
|
|
|
|
{
|
|
|
|
|
++d->connectionAttempts;
|
|
|
|
|
|
2014-05-05 18:01:02 +02:00
|
|
|
if (d->connection && d->connection->isOpen()) {
|
2012-02-24 10:47:17 +01:00
|
|
|
d->connectionTimer.stop();
|
|
|
|
|
d->connectionAttempts = 0;
|
|
|
|
|
} else if (d->connectionAttempts == 50) {
|
|
|
|
|
d->connectionTimer.stop();
|
|
|
|
|
d->connectionAttempts = 0;
|
|
|
|
|
|
|
|
|
|
QMessageBox *infoBox = QmlProfilerTool::requestMessageBox();
|
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
|
infoBox->setText(tr("Could not connect to the in-process QML profiler.\n"
|
|
|
|
|
"Do you want to retry?"));
|
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Retry |
|
|
|
|
|
QMessageBox::Cancel |
|
|
|
|
|
QMessageBox::Help);
|
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
|
|
|
|
infoBox->setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
|
this, SLOT(retryMessageBoxFinished(int)));
|
|
|
|
|
|
|
|
|
|
infoBox->show();
|
|
|
|
|
} else {
|
|
|
|
|
connectToClient();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-05 17:18:11 +02:00
|
|
|
void QmlProfilerClientManager::qmlDebugConnectionOpened()
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2014-05-05 17:18:11 +02:00
|
|
|
logState(tr("Debug connection opened"));
|
|
|
|
|
clientRecordingChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::qmlDebugConnectionClosed()
|
|
|
|
|
{
|
|
|
|
|
logState(tr("Debug connection closed"));
|
|
|
|
|
disconnectClient();
|
|
|
|
|
emit connectionClosed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::logState(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
QString state = QLatin1String("QML Profiler: ") + msg;
|
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
|
|
|
|
qWarning() << state;
|
|
|
|
|
QmlProfilerTool::logState(state);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::retryMessageBoxFinished(int result)
|
|
|
|
|
{
|
2015-07-07 13:16:46 +02:00
|
|
|
if (d->connection) {
|
|
|
|
|
QTC_ASSERT(!d->connection->isOpen(), return);
|
|
|
|
|
if (d->connection->isConnecting())
|
|
|
|
|
d->connection->disconnect();
|
|
|
|
|
}
|
2015-07-06 14:33:49 +02:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
switch (result) {
|
|
|
|
|
case QMessageBox::Retry: {
|
|
|
|
|
d->connectionAttempts = 0;
|
|
|
|
|
d->connectionTimer.start();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::Help: {
|
2013-01-29 15:29:55 +01:00
|
|
|
QmlProfilerTool::handleHelpRequest(QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"));
|
2012-02-24 10:47:17 +01:00
|
|
|
// fall through
|
|
|
|
|
}
|
|
|
|
|
default: {
|
2014-05-05 17:18:11 +02:00
|
|
|
// The actual error message has already been logged.
|
|
|
|
|
logState(tr("Failed to connect!"));
|
2012-02-24 10:47:17 +01:00
|
|
|
emit connectionFailed();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-03 12:33:14 +02:00
|
|
|
void QmlProfilerClientManager::qmlComplete(qint64 maximumTime)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2014-10-14 16:44:45 +02:00
|
|
|
d->modelManager->traceTime()->increaseEndTime(maximumTime);
|
2012-02-24 10:47:17 +01:00
|
|
|
d->qmlDataReady = true;
|
2015-05-26 14:41:27 +02:00
|
|
|
emit dataReadyForProcessing();
|
|
|
|
|
// once complete is sent, reset the flags
|
|
|
|
|
d->qmlDataReady = false;
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::stopClientsRecording()
|
|
|
|
|
{
|
|
|
|
|
if (d->qmlclientplugin)
|
|
|
|
|
d->qmlclientplugin.data()->setRecording(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
|
|
|
|
|
{
|
|
|
|
|
if (d->profilerState) {
|
|
|
|
|
disconnect(d->profilerState, SIGNAL(stateChanged()),
|
|
|
|
|
this, SLOT(profilerStateChanged()));
|
|
|
|
|
disconnect(d->profilerState, SIGNAL(clientRecordingChanged()),
|
|
|
|
|
this, SLOT(clientRecordingChanged()));
|
|
|
|
|
disconnect(d->profilerState, SIGNAL(serverRecordingChanged()),
|
|
|
|
|
this, SLOT(serverRecordingChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->profilerState = profilerState;
|
|
|
|
|
|
|
|
|
|
// connect
|
|
|
|
|
if (d->profilerState) {
|
|
|
|
|
connect(d->profilerState, SIGNAL(stateChanged()),
|
|
|
|
|
this, SLOT(profilerStateChanged()));
|
|
|
|
|
connect(d->profilerState, SIGNAL(clientRecordingChanged()),
|
|
|
|
|
this, SLOT(clientRecordingChanged()));
|
|
|
|
|
connect(d->profilerState, SIGNAL(serverRecordingChanged()),
|
|
|
|
|
this, SLOT(serverRecordingChanged()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::profilerStateChanged()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->profilerState, return);
|
|
|
|
|
switch (d->profilerState->currentState()) {
|
|
|
|
|
case QmlProfilerStateManager::AppStopRequested :
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (d->profilerState->serverRecording())
|
2012-02-24 10:47:17 +01:00
|
|
|
stopClientsRecording();
|
|
|
|
|
else
|
|
|
|
|
d->profilerState->setCurrentState(QmlProfilerStateManager::AppReadyToStop);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::clientRecordingChanged()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->profilerState, return);
|
|
|
|
|
if (d->profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
|
|
|
|
if (d->qmlclientplugin)
|
|
|
|
|
d->qmlclientplugin.data()->setRecording(d->profilerState->clientRecording());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerClientManager::serverRecordingChanged()
|
|
|
|
|
{
|
2015-05-26 14:41:27 +02:00
|
|
|
if (d->profilerState->serverRecording())
|
2012-02-24 10:47:17 +01:00
|
|
|
d->qmlDataReady = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|