forked from qt-creator/qt-creator
Remove TimelineTraceManager::State
This is redundant, now that we have registerFeatures(). Change-Id: Ia56c28b8892ab6da694570fe4b9ea5c96fe194f1 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -40,8 +40,6 @@ class TimelineTraceManager::TimelineTraceManagerPrivate
|
|||||||
public:
|
public:
|
||||||
TimelineNotesModel *notesModel = nullptr;
|
TimelineNotesModel *notesModel = nullptr;
|
||||||
|
|
||||||
TimelineTraceManager::State state = Empty;
|
|
||||||
|
|
||||||
int numEvents = 0;
|
int numEvents = 0;
|
||||||
int numEventTypes = 0;
|
int numEventTypes = 0;
|
||||||
quint64 availableFeatures = 0;
|
quint64 availableFeatures = 0;
|
||||||
@@ -61,7 +59,6 @@ public:
|
|||||||
|
|
||||||
void dispatch(const TraceEvent &event, const TraceEventType &type);
|
void dispatch(const TraceEvent &event, const TraceEventType &type);
|
||||||
void reset();
|
void reset();
|
||||||
void setState(TimelineTraceManager *q, TimelineTraceManager::State state);
|
|
||||||
void updateTraceTime(qint64 time);
|
void updateTraceTime(qint64 time);
|
||||||
void restrictTraceTimeToRange(qint64 start, qint64 end);
|
void restrictTraceTimeToRange(qint64 start, qint64 end);
|
||||||
};
|
};
|
||||||
@@ -184,20 +181,15 @@ void TimelineTraceManager::initialize()
|
|||||||
{
|
{
|
||||||
for (const Initializer &initializer : qAsConst(d->initializers))
|
for (const Initializer &initializer : qAsConst(d->initializers))
|
||||||
initializer();
|
initializer();
|
||||||
|
|
||||||
d->setState(this, AcquiringData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineTraceManager::finalize()
|
void TimelineTraceManager::finalize()
|
||||||
{
|
{
|
||||||
QTC_CHECK(state() == AcquiringData);
|
|
||||||
// Load notes after the timeline models have been initialized ...
|
// Load notes after the timeline models have been initialized ...
|
||||||
// which happens on stateChanged(Done).
|
// which happens on stateChanged(Done).
|
||||||
|
|
||||||
for (const Finalizer &finalizer : qAsConst(d->finalizers))
|
for (const Finalizer &finalizer : qAsConst(d->finalizers))
|
||||||
finalizer();
|
finalizer();
|
||||||
|
|
||||||
d->setState(this, Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<void> TimelineTraceManager::save(const QString &filename)
|
QFuture<void> TimelineTraceManager::save(const QString &filename)
|
||||||
@@ -335,35 +327,6 @@ void TimelineTraceManager::increaseTraceEnd(qint64 end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineTraceManager::TimelineTraceManagerPrivate::setState(
|
|
||||||
TimelineTraceManager *q, TimelineTraceManager::State newState)
|
|
||||||
{
|
|
||||||
// It's not an error, we are continuously calling "AcquiringData" for example
|
|
||||||
if (newState == state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (newState) {
|
|
||||||
case ClearingData:
|
|
||||||
QTC_CHECK(state == Done || state == Empty || state == AcquiringData);
|
|
||||||
break;
|
|
||||||
case Empty:
|
|
||||||
// if it's not empty, complain but go on
|
|
||||||
QTC_CHECK(q->isEmpty());
|
|
||||||
break;
|
|
||||||
case AcquiringData:
|
|
||||||
break;
|
|
||||||
case Done:
|
|
||||||
QTC_ASSERT(state == AcquiringData || state == Empty, return);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
QTC_ASSERT(false, return);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = newState;
|
|
||||||
emit q->stateChanged(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimelineTraceManager::TimelineTraceManagerPrivate::updateTraceTime(qint64 time)
|
void TimelineTraceManager::TimelineTraceManagerPrivate::updateTraceTime(qint64 time)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(time >= 0, return);
|
QTC_ASSERT(time >= 0, return);
|
||||||
@@ -382,12 +345,6 @@ void TimelineTraceManager::TimelineTraceManagerPrivate::restrictTraceTimeToRange
|
|||||||
restrictedTraceEnd = end;
|
restrictedTraceEnd = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimelineTraceManager::State TimelineTraceManager::state() const
|
|
||||||
{
|
|
||||||
return d->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimelineTraceManager::setNotesModel(TimelineNotesModel *notesModel)
|
void TimelineTraceManager::setNotesModel(TimelineNotesModel *notesModel)
|
||||||
{
|
{
|
||||||
d->notesModel = notesModel;
|
d->notesModel = notesModel;
|
||||||
@@ -410,17 +367,13 @@ void TimelineTraceManager::clearTypeStorage()
|
|||||||
|
|
||||||
void TimelineTraceManager::clear()
|
void TimelineTraceManager::clear()
|
||||||
{
|
{
|
||||||
d->setState(this, ClearingData);
|
|
||||||
clearEventStorage();
|
clearEventStorage();
|
||||||
d->setState(this, Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineTraceManager::clearAll()
|
void TimelineTraceManager::clearAll()
|
||||||
{
|
{
|
||||||
d->setState(this, ClearingData);
|
|
||||||
clearEventStorage();
|
clearEventStorage();
|
||||||
clearTypeStorage();
|
clearTypeStorage();
|
||||||
d->setState(this, Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineTraceManager::restrictToRange(qint64 startTime, qint64 endTime)
|
void TimelineTraceManager::restrictToRange(qint64 startTime, qint64 endTime)
|
||||||
@@ -428,7 +381,6 @@ void TimelineTraceManager::restrictToRange(qint64 startTime, qint64 endTime)
|
|||||||
if (d->notesModel)
|
if (d->notesModel)
|
||||||
d->notesModel->stash();
|
d->notesModel->stash();
|
||||||
|
|
||||||
d->setState(this, ClearingData);
|
|
||||||
d->reset();
|
d->reset();
|
||||||
setVisibleFeatures(0);
|
setVisibleFeatures(0);
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ class TIMELINE_EXPORT TimelineTraceManager : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum State {
|
|
||||||
Empty,
|
|
||||||
AcquiringData,
|
|
||||||
ClearingData,
|
|
||||||
Done
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::function<void(const TraceEvent &, const TraceEventType &)> TraceEventLoader;
|
typedef std::function<void(const TraceEvent &, const TraceEventType &)> TraceEventLoader;
|
||||||
typedef std::function<void()> Initializer;
|
typedef std::function<void()> Initializer;
|
||||||
typedef std::function<void()> Finalizer;
|
typedef std::function<void()> Finalizer;
|
||||||
@@ -58,8 +51,6 @@ public:
|
|||||||
explicit TimelineTraceManager(QObject *parent = nullptr);
|
explicit TimelineTraceManager(QObject *parent = nullptr);
|
||||||
~TimelineTraceManager();
|
~TimelineTraceManager();
|
||||||
|
|
||||||
State state() const;
|
|
||||||
|
|
||||||
qint64 traceStart() const;
|
qint64 traceStart() const;
|
||||||
qint64 traceEnd() const;
|
qint64 traceEnd() const;
|
||||||
qint64 traceDuration() const;
|
qint64 traceDuration() const;
|
||||||
@@ -99,7 +90,6 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
void stateChanged(State state);
|
|
||||||
void loadFinished();
|
void loadFinished();
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
|
|
||||||
|
|||||||
@@ -159,8 +159,6 @@ void FlameGraphModel::restrictToFeatures(quint64 visibleFeatures)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_acceptedFeatures = visibleFeatures;
|
m_acceptedFeatures = visibleFeatures;
|
||||||
if (m_modelManager->state() != QmlProfilerModelManager::Done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
|
|||||||
@@ -341,7 +341,6 @@ const char *QmlProfilerModelManager::featureName(ProfileFeature feature)
|
|||||||
|
|
||||||
void QmlProfilerModelManager::finalize()
|
void QmlProfilerModelManager::finalize()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == AcquiringData, /**/);
|
|
||||||
if (!d->file.flush())
|
if (!d->file.flush())
|
||||||
emit error(tr("Failed to flush temporary trace file"));
|
emit error(tr("Failed to flush temporary trace file"));
|
||||||
d->detailsRewriter->reloadDocuments();
|
d->detailsRewriter->reloadDocuments();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -72,17 +74,16 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan
|
|||||||
|
|
||||||
// profiler state
|
// profiler state
|
||||||
d->m_modelManager = modelManager;
|
d->m_modelManager = modelManager;
|
||||||
connect(d->m_modelManager, &QmlProfilerModelManager::stateChanged,
|
|
||||||
this, &QmlProfilerStateWidget::update);
|
modelManager->registerFeatures(0, QmlProfilerModelManager::QmlEventLoader(),
|
||||||
|
std::bind(&QmlProfilerStateWidget::initialize, this),
|
||||||
|
std::bind(&QmlProfilerStateWidget::clear, this),
|
||||||
|
std::bind(&QmlProfilerStateWidget::clear, this));
|
||||||
d->m_profilerState = stateManager;
|
d->m_profilerState = stateManager;
|
||||||
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
|
||||||
this, &QmlProfilerStateWidget::update);
|
|
||||||
connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
|
|
||||||
this, &QmlProfilerStateWidget::update);
|
|
||||||
connect(&d->timer, &QTimer::timeout, this, &QmlProfilerStateWidget::updateDisplay);
|
connect(&d->timer, &QTimer::timeout, this, &QmlProfilerStateWidget::updateDisplay);
|
||||||
|
|
||||||
d->timer.setInterval(1000);
|
d->timer.setInterval(1000);
|
||||||
update();
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerStateWidget::~QmlProfilerStateWidget()
|
QmlProfilerStateWidget::~QmlProfilerStateWidget()
|
||||||
@@ -97,6 +98,16 @@ void QmlProfilerStateWidget::reposition()
|
|||||||
move(parentWidget->width()/2 - width()/2, parentWidget->height()/3 - height()/2);
|
move(parentWidget->width()/2 - width()/2, parentWidget->height()/3 - height()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerStateWidget::initialize()
|
||||||
|
{
|
||||||
|
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
||||||
|
this, &QmlProfilerStateWidget::updateDisplay);
|
||||||
|
connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
|
||||||
|
this, &QmlProfilerStateWidget::updateDisplay);
|
||||||
|
d->timer.start();
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlProfilerStateWidget::showText(const QString &text)
|
void QmlProfilerStateWidget::showText(const QString &text)
|
||||||
{
|
{
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
@@ -105,69 +116,45 @@ void QmlProfilerStateWidget::showText(const QString &text)
|
|||||||
reposition();
|
reposition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerStateWidget::clear()
|
||||||
|
{
|
||||||
|
disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
||||||
|
this, &QmlProfilerStateWidget::updateDisplay);
|
||||||
|
disconnect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
|
||||||
|
this, &QmlProfilerStateWidget::updateDisplay);
|
||||||
|
d->timer.stop();
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void QmlProfilerStateWidget::updateDisplay()
|
void QmlProfilerStateWidget::updateDisplay()
|
||||||
{
|
{
|
||||||
if (!d->m_modelManager || !d->m_profilerState) {
|
QTC_ASSERT(d->m_modelManager, return);
|
||||||
d->timer.stop();
|
QTC_ASSERT(d->m_profilerState, return);
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When application is being profiled
|
// When application is being profiled
|
||||||
if (d->m_profilerState->serverRecording()) {
|
if (d->m_profilerState->serverRecording()) {
|
||||||
// Heuristic to not show the number if the application will only send the events when it
|
// Heuristic to not show the number if the application will only send the events when it
|
||||||
// stops. The number is still > 0 then because we get some StartTrace etc.
|
// stops. The number is still > 0 then because we get some StartTrace etc.
|
||||||
uint numEvents = d->m_modelManager->numEvents();
|
const int numEvents = d->m_modelManager->numEvents();
|
||||||
showText(numEvents > 256 ? tr("Profiling application: %n events", nullptr, numEvents) :
|
showText(numEvents > 256 ? tr("Profiling application: %n events", nullptr, numEvents) :
|
||||||
tr("Profiling application"));
|
tr("Profiling application"));
|
||||||
return;
|
} else if (d->m_modelManager->traceDuration() > 0 && d->m_modelManager->isEmpty()) {
|
||||||
}
|
|
||||||
|
|
||||||
QmlProfilerModelManager::State state = d->m_modelManager->state();
|
|
||||||
if (state == QmlProfilerModelManager::Done || state == QmlProfilerModelManager::Empty) {
|
|
||||||
// After profiling, there is an empty trace
|
// After profiling, there is an empty trace
|
||||||
if (d->m_modelManager->traceDuration() > 0 && d->m_modelManager->isEmpty()) {
|
showText(tr("No QML events recorded"));
|
||||||
showText(tr("No QML events recorded"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (!d->m_modelManager->isEmpty()) {
|
} else if (!d->m_modelManager->isEmpty()) {
|
||||||
// When datamodel is acquiring or processing data
|
// When datamodel is acquiring data
|
||||||
if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle) {
|
if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle) {
|
||||||
if (state == QmlProfilerModelManager::AcquiringData) {
|
// we don't know how much more, so progress numbers are strange here
|
||||||
// we don't know how much more, so progress numbers are strange here
|
showText(tr("Loading buffered data: %n events", nullptr,
|
||||||
showText(tr("Loading buffered data: %n events", nullptr,
|
d->m_modelManager->numEvents()));
|
||||||
d->m_modelManager->numEvents()));
|
} else {
|
||||||
} else if (state == QmlProfilerModelManager::ClearingData) {
|
|
||||||
// when starting a second recording from the same process without aggregation
|
|
||||||
showText(tr("Clearing old trace"));
|
|
||||||
}
|
|
||||||
} else if (state == QmlProfilerModelManager::AcquiringData) {
|
|
||||||
// Application died before all data could be read
|
// Application died before all data could be read
|
||||||
showText(tr("Loading offline data: %n events", nullptr,
|
showText(tr("Loading offline data: %n events", nullptr,
|
||||||
d->m_modelManager->numEvents()));
|
d->m_modelManager->numEvents()));
|
||||||
} else if (state == QmlProfilerModelManager::ClearingData) {
|
|
||||||
showText(tr("Clearing old trace"));
|
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
} else if (state == QmlProfilerModelManager::AcquiringData) {
|
|
||||||
showText(tr("Waiting for data"));
|
showText(tr("Waiting for data"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a trace on view, hide this dialog
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerStateWidget::update()
|
|
||||||
{
|
|
||||||
QmlProfilerModelManager::State state = d->m_modelManager ? d->m_modelManager->state()
|
|
||||||
: QmlProfilerModelManager::Empty;
|
|
||||||
if (state == QmlProfilerModelManager::AcquiringData)
|
|
||||||
d->timer.start();
|
|
||||||
else
|
|
||||||
d->timer.stop();
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
void showText(const QString &text);
|
void showText(const QString &text);
|
||||||
void updateDisplay();
|
void updateDisplay();
|
||||||
void update();
|
|
||||||
void reposition();
|
void reposition();
|
||||||
|
void initialize();
|
||||||
|
void clear();
|
||||||
|
|
||||||
class QmlProfilerStateWidgetPrivate;
|
class QmlProfilerStateWidgetPrivate;
|
||||||
QmlProfilerStateWidgetPrivate *d;
|
QmlProfilerStateWidgetPrivate *d;
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ void QmlProfilerStatisticsModel::restrictToFeatures(quint64 features)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!didChange || m_modelManager->state() != QmlProfilerModelManager::Done)
|
|
||||||
|
if (!didChange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|||||||
@@ -149,8 +149,11 @@ QmlProfilerTool::QmlProfilerTool()
|
|||||||
this, &QmlProfilerTool::clientsDisconnected);
|
this, &QmlProfilerTool::clientsDisconnected);
|
||||||
|
|
||||||
d->m_profilerModelManager = new QmlProfilerModelManager(this);
|
d->m_profilerModelManager = new QmlProfilerModelManager(this);
|
||||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::stateChanged,
|
d->m_profilerModelManager->registerFeatures(0, QmlProfilerModelManager::QmlEventLoader(),
|
||||||
this, &QmlProfilerTool::profilerDataModelStateChanged);
|
std::bind(&QmlProfilerTool::initialize, this),
|
||||||
|
std::bind(&QmlProfilerTool::finalize, this),
|
||||||
|
std::bind(&QmlProfilerTool::clear, this));
|
||||||
|
|
||||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::error,
|
connect(d->m_profilerModelManager, &QmlProfilerModelManager::error,
|
||||||
this, &QmlProfilerTool::showErrorDialog);
|
this, &QmlProfilerTool::showErrorDialog);
|
||||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::availableFeaturesChanged,
|
connect(d->m_profilerModelManager, &QmlProfilerModelManager::availableFeaturesChanged,
|
||||||
@@ -305,21 +308,6 @@ QmlProfilerTool::QmlProfilerTool()
|
|||||||
d->m_recordButton->setToolTip(recording ? tr("Disable Profiling") : tr("Enable Profiling"));
|
d->m_recordButton->setToolTip(recording ? tr("Disable Profiling") : tr("Enable Profiling"));
|
||||||
d->m_recordButton->setIcon(recording ? recordOn : recordOff);
|
d->m_recordButton->setIcon(recording ? recordOn : recordOff);
|
||||||
d->m_recordButton->setChecked(recording);
|
d->m_recordButton->setChecked(recording);
|
||||||
|
|
||||||
switch (d->m_profilerModelManager->state()) {
|
|
||||||
case QmlProfilerModelManager::Empty:
|
|
||||||
case QmlProfilerModelManager::AcquiringData:
|
|
||||||
case QmlProfilerModelManager::Done:
|
|
||||||
// Don't change the recording button if the application cannot react to it.
|
|
||||||
d->m_recordButton->setEnabled(d->m_profilerState->currentState()
|
|
||||||
!= QmlProfilerStateManager::AppStopRequested
|
|
||||||
&& d->m_profilerState->currentState()
|
|
||||||
!= QmlProfilerStateManager::AppDying);
|
|
||||||
break;
|
|
||||||
case QmlProfilerModelManager::ClearingData:
|
|
||||||
d->m_recordButton->setEnabled(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
||||||
@@ -328,8 +316,6 @@ QmlProfilerTool::QmlProfilerTool()
|
|||||||
d->m_recordButton, updateRecordButton);
|
d->m_recordButton, updateRecordButton);
|
||||||
connect(d->m_profilerState, &QmlProfilerStateManager::clientRecordingChanged,
|
connect(d->m_profilerState, &QmlProfilerStateManager::clientRecordingChanged,
|
||||||
d->m_recordButton, updateRecordButton);
|
d->m_recordButton, updateRecordButton);
|
||||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::stateChanged,
|
|
||||||
d->m_recordButton, updateRecordButton);
|
|
||||||
updateRecordButton();
|
updateRecordButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,11 +420,9 @@ void QmlProfilerTool::recordingButtonChanged(bool recording)
|
|||||||
{
|
{
|
||||||
// clientRecording is our intention for new sessions. That may differ from the state of the
|
// clientRecording is our intention for new sessions. That may differ from the state of the
|
||||||
// current session, as indicated by the button. To synchronize it, toggle once.
|
// current session, as indicated by the button. To synchronize it, toggle once.
|
||||||
|
|
||||||
if (recording && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
if (recording && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
||||||
if (checkForUnsavedNotes()) {
|
if (checkForUnsavedNotes()) {
|
||||||
if (!d->m_profilerModelManager->aggregateTraces() ||
|
if (!d->m_profilerModelManager->aggregateTraces())
|
||||||
d->m_profilerModelManager->state() == QmlProfilerModelManager::Done)
|
|
||||||
clearEvents(); // clear before the recording starts, unless we aggregate recordings
|
clearEvents(); // clear before the recording starts, unless we aggregate recordings
|
||||||
if (d->m_profilerState->clientRecording())
|
if (d->m_profilerState->clientRecording())
|
||||||
d->m_profilerState->setClientRecording(false);
|
d->m_profilerState->setClientRecording(false);
|
||||||
@@ -485,8 +469,7 @@ void QmlProfilerTool::updateTimeDisplay()
|
|||||||
}
|
}
|
||||||
Q_FALLTHROUGH();
|
Q_FALLTHROUGH();
|
||||||
case QmlProfilerStateManager::Idle:
|
case QmlProfilerStateManager::Idle:
|
||||||
if (d->m_profilerModelManager->state() != QmlProfilerModelManager::Empty &&
|
if (d->m_profilerModelManager->traceDuration() > 0)
|
||||||
d->m_profilerModelManager->state() != QmlProfilerModelManager::ClearingData)
|
|
||||||
seconds = d->m_profilerModelManager->traceDuration() / 1.0e9;
|
seconds = d->m_profilerModelManager->traceDuration() / 1.0e9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -735,7 +718,7 @@ void QmlProfilerTool::restoreFeatureVisibility()
|
|||||||
|
|
||||||
void QmlProfilerTool::clientsDisconnected()
|
void QmlProfilerTool::clientsDisconnected()
|
||||||
{
|
{
|
||||||
if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) {
|
if (d->m_toolBusy) {
|
||||||
if (d->m_profilerModelManager->aggregateTraces()) {
|
if (d->m_profilerModelManager->aggregateTraces()) {
|
||||||
d->m_profilerModelManager->finalize();
|
d->m_profilerModelManager->finalize();
|
||||||
} else {
|
} else {
|
||||||
@@ -802,28 +785,27 @@ void QmlProfilerTool::setRecordedFeatures(quint64 features)
|
|||||||
action->setEnabled(features & (1ULL << action->data().toUInt()));
|
action->setEnabled(features & (1ULL << action->data().toUInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::profilerDataModelStateChanged()
|
void QmlProfilerTool::initialize()
|
||||||
{
|
{
|
||||||
switch (d->m_profilerModelManager->state()) {
|
restoreFeatureVisibility();
|
||||||
case QmlProfilerModelManager::Empty :
|
setButtonsEnabled(false); // Other buttons disabled
|
||||||
setButtonsEnabled(true);
|
}
|
||||||
break;
|
|
||||||
case QmlProfilerModelManager::ClearingData :
|
void QmlProfilerTool::finalize()
|
||||||
clearTextMarks();
|
{
|
||||||
setButtonsEnabled(false);
|
showSaveOption();
|
||||||
clearDisplay();
|
updateTimeDisplay();
|
||||||
break;
|
createTextMarks();
|
||||||
case QmlProfilerModelManager::AcquiringData :
|
setButtonsEnabled(true);
|
||||||
restoreFeatureVisibility();
|
d->m_recordButton->setEnabled(true);
|
||||||
setButtonsEnabled(false); // Other buttons disabled
|
}
|
||||||
break;
|
|
||||||
case QmlProfilerModelManager::Done :
|
void QmlProfilerTool::clear()
|
||||||
showSaveOption();
|
{
|
||||||
updateTimeDisplay();
|
clearTextMarks();
|
||||||
setButtonsEnabled(true);
|
clearDisplay();
|
||||||
createTextMarks();
|
setButtonsEnabled(true);
|
||||||
break;
|
d->m_recordButton->setEnabled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList <QAction *> QmlProfilerTool::profilerContextMenuActions()
|
QList <QAction *> QmlProfilerTool::profilerContextMenuActions()
|
||||||
@@ -913,8 +895,7 @@ void QmlProfilerTool::serverRecordingChanged()
|
|||||||
|
|
||||||
d->m_recordingTimer.start();
|
d->m_recordingTimer.start();
|
||||||
d->m_recordingElapsedTime.start();
|
d->m_recordingElapsedTime.start();
|
||||||
if (!d->m_profilerModelManager->aggregateTraces() ||
|
if (!d->m_profilerModelManager->aggregateTraces())
|
||||||
d->m_profilerModelManager->state() == QmlProfilerModelManager::Done)
|
|
||||||
clearEvents();
|
clearEvents();
|
||||||
d->m_profilerModelManager->initialize();
|
d->m_profilerModelManager->initialize();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ private:
|
|||||||
void createTextMarks();
|
void createTextMarks();
|
||||||
void clearTextMarks();
|
void clearTextMarks();
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
void finalize();
|
||||||
|
void clear();
|
||||||
|
|
||||||
class QmlProfilerToolPrivate;
|
class QmlProfilerToolPrivate;
|
||||||
QmlProfilerToolPrivate *d;
|
QmlProfilerToolPrivate *d;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,33 +96,27 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
setObjectName("QmlProfiler.Timeline.Dock");
|
setObjectName("QmlProfiler.Timeline.Dock");
|
||||||
|
|
||||||
d->m_zoomControl = new Timeline::TimelineZoomControl(this);
|
d->m_zoomControl = new Timeline::TimelineZoomControl(this);
|
||||||
connect(modelManager, &QmlProfilerModelManager::stateChanged, this, [modelManager, this]() {
|
modelManager->registerFeatures(0, QmlProfilerModelManager::QmlEventLoader(), [this]() {
|
||||||
switch (modelManager->state()) {
|
if (d->m_suspendedModels.isEmpty()) {
|
||||||
case QmlProfilerModelManager::Done: {
|
// Temporarily remove the models, while we're changing them
|
||||||
const qint64 start = modelManager->traceStart();
|
d->m_suspendedModels = d->m_modelProxy->models();
|
||||||
const qint64 end = modelManager->traceEnd();
|
d->m_modelProxy->setModels(QVariantList());
|
||||||
d->m_zoomControl->setTrace(start, end);
|
|
||||||
d->m_zoomControl->setRange(start, start + (end - start) / 10);
|
|
||||||
Q_FALLTHROUGH();
|
|
||||||
}
|
}
|
||||||
case QmlProfilerModelManager::Empty:
|
// Otherwise models are suspended already. This can happen if either acquiring was
|
||||||
|
// aborted or we're doing a "restrict to range" which consists of a partial clearing and
|
||||||
|
// then re-acquiring of data.
|
||||||
|
}, [this, modelManager]() {
|
||||||
|
const qint64 start = modelManager->traceStart();
|
||||||
|
const qint64 end = modelManager->traceEnd();
|
||||||
|
d->m_zoomControl->setTrace(start, end);
|
||||||
|
d->m_zoomControl->setRange(start, start + (end - start) / 10);
|
||||||
|
d->m_modelProxy->setModels(d->m_suspendedModels);
|
||||||
|
d->m_suspendedModels.clear();
|
||||||
|
}, [this]() {
|
||||||
|
d->m_zoomControl->clear();
|
||||||
|
if (!d->m_suspendedModels.isEmpty()) {
|
||||||
d->m_modelProxy->setModels(d->m_suspendedModels);
|
d->m_modelProxy->setModels(d->m_suspendedModels);
|
||||||
d->m_suspendedModels.clear();
|
d->m_suspendedModels.clear();
|
||||||
d->m_modelManager->notesModel()->restore();
|
|
||||||
break;
|
|
||||||
case QmlProfilerModelManager::ClearingData:
|
|
||||||
d->m_zoomControl->clear();
|
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QmlProfilerModelManager::AcquiringData:
|
|
||||||
if (d->m_suspendedModels.isEmpty()) {
|
|
||||||
// Temporarily remove the models, while we're changing them
|
|
||||||
d->m_suspendedModels = d->m_modelProxy->models();
|
|
||||||
d->m_modelProxy->setModels(QVariantList());
|
|
||||||
}
|
|
||||||
// Otherwise models are suspended already. This can happen if either acquiring was
|
|
||||||
// aborted or we're doing a "restrict to range" which consists of a partial clearing and
|
|
||||||
// then re-acquiring of data.
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ void DebugMessagesModelTest::initTestCase()
|
|||||||
manager.addEvent(event);
|
manager.addEvent(event);
|
||||||
}
|
}
|
||||||
manager.finalize();
|
manager.finalize();
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugMessagesModelTest::testTypeId()
|
void DebugMessagesModelTest::testTypeId()
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ void FlameGraphModelTest::initTestCase()
|
|||||||
{
|
{
|
||||||
QCOMPARE(model.modelManager(), &manager);
|
QCOMPARE(model.modelManager(), &manager);
|
||||||
rangeModelId = generateData(&manager, &aggregator);
|
rangeModelId = generateData(&manager, &aggregator);
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlameGraphModelTest::testIndex()
|
void FlameGraphModelTest::testIndex()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ void FlameGraphViewTest::initTestCase()
|
|||||||
connect(&view, &QmlProfilerEventsView::showFullRange,
|
connect(&view, &QmlProfilerEventsView::showFullRange,
|
||||||
this, [this](){ manager.restrictToRange(-1, -1); });
|
this, [this](){ manager.restrictToRange(-1, -1); });
|
||||||
FlameGraphModelTest::generateData(&manager, &aggregator);
|
FlameGraphModelTest::generateData(&manager, &aggregator);
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
view.resize(500, 500);
|
view.resize(500, 500);
|
||||||
view.show();
|
view.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ void InputEventsModelTest::initTestCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager.finalize();
|
manager.finalize();
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventsModelTest::testAccepted()
|
void InputEventsModelTest::testAccepted()
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ void MemoryUsageModelTest::initTestCase()
|
|||||||
manager.addEvent(event);
|
manager.addEvent(event);
|
||||||
|
|
||||||
manager.finalize();
|
manager.finalize();
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
QCOMPARE(model.count(), 11);
|
QCOMPARE(model.count(), 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,8 +188,6 @@ void PixmapCacheModelTest::initTestCase()
|
|||||||
|
|
||||||
|
|
||||||
manager.finalize();
|
manager.finalize();
|
||||||
|
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixmapCacheModelTest::testConsistency()
|
void PixmapCacheModelTest::testConsistency()
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ void QmlProfilerAnimationsModelTest::initTestCase()
|
|||||||
manager.addEvent(event);
|
manager.addEvent(event);
|
||||||
}
|
}
|
||||||
manager.finalize();
|
manager.finalize();
|
||||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerAnimationsModelTest::testAccepted()
|
void QmlProfilerAnimationsModelTest::testAccepted()
|
||||||
|
|||||||
Reference in New Issue
Block a user