From 228790f27a4cb8f4f307693fb1c9f13a96eddfaa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 15 Jan 2018 12:28:09 +0100 Subject: QQmlProfilerService: Only send "Complete" if no more engines are running Also, make sure to report all engine's events when stopping one. Otherwise the timestamps will reset when reporting multiple engines in a row (such as when stopping the application). Task-number: QTBUG-65767 Change-Id: I0a6a9170069318dd5b8a7422cb7e248c87d5adce Reviewed-by: Michael Brasser --- .../qmldbg_profiler/qqmlprofilerservice.cpp | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index 4176ede40e..affd2a417e 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -296,10 +296,11 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine) for (QMultiHash::iterator i(m_engineProfilers.begin()); i != m_engineProfilers.end(); ++i) { if (i.value()->isRunning()) { + m_startTimes.insert(-1, i.value()); if (engine == 0 || i.key() == engine) { - m_startTimes.insert(-1, i.value()); stopping << i.value(); } else { + reporting << i.value(); stillRunning = true; } } @@ -368,25 +369,32 @@ void QQmlProfilerServiceImpl::sendMessages() } } + bool stillRunning = false; + for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { + if (profiler->isRunning()) { + stillRunning = true; + break; + } + } + if (m_waitingForStop) { - //indicate completion + // EndTrace can be sent multiple times, as it's engine specific. messages << traceEnd.data(); - QQmlDebugPacket ds; - ds << (qint64)-1 << (int)Complete; - messages << ds.data(); - m_waitingForStop = false; + if (!stillRunning) { + // Complete is only sent once, when no engines are running anymore. + QQmlDebugPacket ds; + ds << (qint64)-1 << (int)Complete; + messages << ds.data(); + m_waitingForStop = false; + } } emit messagesToClient(name(), messages); // Restart flushing if any profilers are still running - for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { - if (profiler->isRunning()) { - emit startFlushTimer(); - break; - } - } + if (stillRunning) + emit startFlushTimer(); } void QQmlProfilerServiceImpl::stateAboutToBeChanged(QQmlDebugService::State newState) -- cgit v1.2.3