bool QQmlProfilerService::startProfilingImpl()
{
bool success = false;
- if (!profilingEnabled()) {
+ if (QQmlDebugService::isDebuggingEnabled() && !profilingEnabled()) {
setProfilingEnabled(true);
sendStartedProfilingMessageImpl();
success = true;
const QByteArray baSource = frame.source.toUtf8();
const QByteArray baFunction = frame.function.toUtf8();
QMessageLogger logger(baSource.constData(), frame.line, baFunction.constData());
- if (QQmlProfilerService::startProfiling()) {
+ if (!QQmlDebugService::isDebuggingEnabled()) {
+ logger.warning("Cannot start profiling because debug service is disabled. Start with -qmljsdebugger=port:XXXXX.");
+ } else if (QQmlProfilerService::startProfiling()) {
QV8ProfilerService::instance()->startProfiling(title);
logger.debug("Profiling started.");
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ console.profile();
+ stopTimer.start();
+ }
+ }
+
+ Timer {
+ id: stopTimer
+ interval: 1000
+ onTriggered: {
+ console.profileEnd();
+ endTimer.start();
+ }
+ }
+
+ Timer {
+ id: endTimer
+ interval: 1000
+ onTriggered: Qt.quit();
+ }
+}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
OTHER_FILES += \
- data/pixmapCacheTest.qml
+ data/pixmapCacheTest.qml \
+ data/controlFromJS.qml
void pixmapCacheData();
void scenegraphData();
void profileOnExit();
+ void controlFromJS();
};
void QQmlProfilerClient::messageReceived(const QByteArray &message)
QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
+void tst_QQmlProfilerService::controlFromJS()
+{
+ connect(true, "controlFromJS.qml");
+ QVERIFY(m_client);
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(false);
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time.");
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
+}
+
QTEST_MAIN(tst_QQmlProfilerService)
#include "tst_qqmlprofilerservice.moc"
QUrl testUrl = testFileUrl("profiling.qml");
// profiling()
- QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
- QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
+ QTest::ignoreMessage(QtWarningMsg, "Cannot start profiling because debug service is disabled. Start with -qmljsdebugger=port:XXXXX.");
+ QTest::ignoreMessage(QtWarningMsg, "Profiling was not started.");
QQmlComponent component(&engine, testUrl);
QObject *object = component.create();