From f3b4c428cdae5a04acc1c550d82f8a409d10ad80 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Wed, 14 Mar 2012 17:35:40 +0100 Subject: [PATCH] QmlProfiler: fix broken recording logic from the client side This patch should not be applied back to the master branch, since the issues are already fixed by b7304e2f2e. Task-number: QTCREATORBUG-7091 Change-Id: I6f0b7752f3446b412c5bd9ae6e3d7e1847472e56 Reviewed-by: Kai Koehne --- .../qmljsdebugclient/qmlprofilereventlist.cpp | 11 ++++++--- src/plugins/qmlprofiler/qml/MainView.qml | 2 +- src/plugins/qmlprofiler/qmlprofilertool.cpp | 3 ++- src/plugins/qmlprofiler/tracewindow.cpp | 23 ++++++++++++++++--- src/plugins/qmlprofiler/tracewindow.h | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp index a4079669cef..d056f92a4dd 100644 --- a/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp +++ b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp @@ -644,9 +644,14 @@ void QmlProfilerEventList::setTraceStartTime( qint64 time ) void QmlProfilerEventList::complete() { - setState(ProcessingData); - d->collectV8Statistics(); - postProcess(); + if (currentState() == AcquiringData) { + setState(ProcessingData); + d->collectV8Statistics(); + postProcess(); + } else { + setState(Empty); + } + } void QmlProfilerEventList::QmlProfilerEventListPrivate::clearQmlRootEvent() diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 9fc2e8e44ed..ae2b9a81226 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -321,7 +321,7 @@ Rectangle { id: elapsedTimer property date startDate property bool reset: true - running: connection.recording && connection.enabled + running: connection ? (connection.recording && connection.enabled) : false repeat: true onRunningChanged: { if (running) reset = true; diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 24c6887869b..645096e7f90 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -533,7 +533,8 @@ QWidget *QmlProfilerTool::createWidgets() void QmlProfilerTool::connectClient(int port) { - QTC_ASSERT(!d->m_client, return;) + if (d->m_client) + delete d->m_client; d->m_client = new QDeclarativeDebugConnection; d->m_traceWindow->reset(d->m_client); connect(d->m_client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index 6a4f3817fb4..f075c49ac69 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -154,6 +154,8 @@ TraceWindow::TraceWindow(QWidget *parent) setMinimumHeight(170); m_currentZoomLevel = 0; m_profiledTime = 0; + + initializeQmlViews(); } TraceWindow::~TraceWindow() @@ -276,6 +278,14 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn) connectClientSignals(); + m_v8DataReady = false; + m_qmlDataReady = false; + + m_mainView->rootContext()->setContextProperty("connection", m_plugin.data()); +} + +void TraceWindow::initializeQmlViews() +{ m_mainView->rootContext()->setContextProperty("connection", m_plugin.data()); m_mainView->rootContext()->setContextProperty("zoomControl", m_zoomControl.data()); m_timebar->rootContext()->setContextProperty("zoomControl", m_zoomControl.data()); @@ -307,9 +317,6 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn) connect(this, SIGNAL(internalClearDisplay()), m_mainView->rootObject(), SLOT(clearAll())); connect(this,SIGNAL(internalClearDisplay()), m_overview->rootObject(), SLOT(clearDisplay())); - - m_v8DataReady = false; - m_qmlDataReady = false; } void TraceWindow::connectClientSignals() @@ -476,6 +483,11 @@ void TraceWindow::qmlComplete() m_qmlDataReady = true; if (!m_v8plugin || m_v8plugin.data()->status() != QDeclarativeDebugClient::Enabled || m_v8DataReady) { m_eventList->complete(); + + // if no data was received, still notify completion + if (m_eventList->currentState() == QmlProfilerEventList::Empty) + emit viewUpdated(); + // once complete is sent, reset the flags m_qmlDataReady = false; m_v8DataReady = false; @@ -487,6 +499,11 @@ void TraceWindow::v8Complete() m_v8DataReady = true; if (!m_plugin || m_plugin.data()->status() != QDeclarativeDebugClient::Enabled || m_qmlDataReady) { m_eventList->complete(); + + // if no data was received, still notify completion + if (m_eventList->currentState() == QmlProfilerEventList::Empty) + emit viewUpdated(); + // once complete is sent, reset the flags m_v8DataReady = false; m_qmlDataReady = false; diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index 2959720db64..2c653e5c0a4 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -170,6 +170,7 @@ private: QWidget *createZoomToolbar(); void connectClientSignals(); void disconnectClientSignals(); + void initializeQmlViews(); protected: virtual void resizeEvent(QResizeEvent *event);