diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-02-07 17:25:24 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-02-08 08:42:13 +0000 |
commit | 02c5209db58ae000bdd5066e9bc4cc6c875646f7 (patch) | |
tree | 2e666cb22d12f4b8c2d0e94becf84a2aed5f9e9f | |
parent | cefd0913c302c0821a0d40e95f5f85113e9f17db (diff) |
QmlDebug: Use EngineControl to hold engines until we're done with them
Holding the engines with EngineControl makes sure we always receive the
full trace before the connection drops.
Task-number: QTBUG-66269
Change-Id: I9177c2a52743ba781547696508342c8d98557121
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qmldebug/qqmlprofilerclient.cpp | 27 | ||||
-rw-r--r-- | src/qmldebug/qqmlprofilerclient_p_p.h | 2 | ||||
-rw-r--r-- | tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST | 10 | ||||
-rw-r--r-- | tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp | 7 |
4 files changed, 29 insertions, 17 deletions
diff --git a/src/qmldebug/qqmlprofilerclient.cpp b/src/qmldebug/qqmlprofilerclient.cpp index dca564cd76..cbd0062ce6 100644 --- a/src/qmldebug/qqmlprofilerclient.cpp +++ b/src/qmldebug/qqmlprofilerclient.cpp @@ -168,6 +168,22 @@ QQmlProfilerClient::QQmlProfilerClient(QQmlDebugConnection *connection, setRequestedFeatures(features); connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeAdded, this, &QQmlProfilerClient::sendRecordingStatus); + connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeRemoved, + this, [d](int engineId) { + // We may already be done with that engine. Then we don't need to block it. + if (d->trackedEngines.contains(engineId)) + d->engineControl->blockEngine(engineId); + }); + connect(this, &QQmlProfilerClient::traceFinished, + d->engineControl.data(), [d](qint64 timestamp, const QList<int> &engineIds) { + Q_UNUSED(timestamp); + // The engines might not be blocked because the trace can get finished before engine control + // sees them. + for (int blocked : d->engineControl->blockedEngines()) { + if (engineIds.contains(blocked)) + d->engineControl->releaseEngine(blocked); + } + }); } QQmlProfilerClient::~QQmlProfilerClient() @@ -322,12 +338,15 @@ void QQmlProfilerClient::messageReceived(const QByteArray &data) emit complete(d->maximumTime); } else if (d->currentEvent.type.message() == Event && d->currentEvent.type.detailType() == StartTrace) { - emit traceStarted(d->currentEvent.event.timestamp(), - d->currentEvent.event.numbers<QList<int>, qint32>()); + const QList<int> engineIds = d->currentEvent.event.numbers<QList<int>, qint32>(); + d->trackedEngines.append(engineIds); + emit traceStarted(d->currentEvent.event.timestamp(), engineIds); } else if (d->currentEvent.type.message() == Event && d->currentEvent.type.detailType() == EndTrace) { - emit traceFinished(d->currentEvent.event.timestamp(), - d->currentEvent.event.numbers<QList<int>, qint32>()); + const QList<int> engineIds = d->currentEvent.event.numbers<QList<int>, qint32>(); + for (int engineId : engineIds) + d->trackedEngines.removeAll(engineId); + emit traceFinished(d->currentEvent.event.timestamp(), engineIds); } else if (d->updateFeatures(d->currentEvent.type.feature())) { d->processCurrentEvent(); } diff --git a/src/qmldebug/qqmlprofilerclient_p_p.h b/src/qmldebug/qqmlprofilerclient_p_p.h index cf0145409a..0caef8e448 100644 --- a/src/qmldebug/qqmlprofilerclient_p_p.h +++ b/src/qmldebug/qqmlprofilerclient_p_p.h @@ -105,6 +105,8 @@ public: QStack<QQmlProfilerTypedEvent> rangesInProgress; QQueue<QQmlProfilerEvent> pendingMessages; QQueue<QQmlProfilerEvent> pendingDebugMessages; + + QList<int> trackedEngines; }; QT_END_NAMESPACE diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST b/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST deleted file mode 100644 index 30e254e164..0000000000 --- a/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST +++ /dev/null @@ -1,10 +0,0 @@ -# QTBUG-66230 -[profileOnExit] -osx -windows -[translationBinding] -osx -windows -[memory] -osx -windows diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index c32fa7ea7d..90c61afe13 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -244,9 +244,10 @@ QQmlDebugTest::ConnectResult tst_QQmlProfilerService::connect( m_isComplete = false; // ### Still using qmlscene due to QTBUG-33377 - return QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", - restrictServices ? QStringLiteral("CanvasFrameRate") : QString(), - testFile(file), block); + return QQmlDebugTest::connect( + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", + restrictServices ? QQmlDebuggingEnabler::profilerServices().join(',') : QString(), + testFile(file), block); } void tst_QQmlProfilerService::checkProcessTerminated() |