forked from qt-creator/qt-creator
QmlProfiler: Rebuild the flamegraph model when visible features change
This is more expensive than just setting the filtered items' height to 0. However, this way we implicitly also change the size of the root element, group equal items that end up on the same level by filtering, recalculate the cutoff for too small items and resort all items by width. Change-Id: Ida2c5acd9848c5644ecff052d78e9fe5ad962606 Task-number: QTCREATORBUG-18713 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -38,6 +38,11 @@
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
static inline quint64 supportedFeatures()
|
||||
{
|
||||
return Constants::QML_JS_RANGE_FEATURES | (1ULL << ProfileMemory);
|
||||
}
|
||||
|
||||
FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager,
|
||||
QObject *parent) : QAbstractItemModel(parent)
|
||||
{
|
||||
@@ -51,8 +56,9 @@ FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager,
|
||||
connect(modelManager->notesModel(), &Timeline::TimelineNotesModel::changed,
|
||||
this, [this](int typeId, int, int){loadNotes(typeId, true);});
|
||||
m_modelId = modelManager->registerModelProxy();
|
||||
m_acceptedFeatures = supportedFeatures();
|
||||
|
||||
modelManager->announceFeatures(Constants::QML_JS_RANGE_FEATURES | 1 << ProfileMemory,
|
||||
modelManager->announceFeatures(m_acceptedFeatures,
|
||||
[this](const QmlEvent &event, const QmlEventType &type) {
|
||||
loadEvent(event, type);
|
||||
}, [this](){
|
||||
@@ -98,7 +104,8 @@ void FlameGraphModel::loadNotes(int typeIndex, bool emitSignal)
|
||||
|
||||
void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
if (!(m_acceptedFeatures & (1ULL << type.feature())))
|
||||
return;
|
||||
|
||||
if (m_stackBottom.children.isEmpty())
|
||||
beginResetModel();
|
||||
@@ -150,6 +157,31 @@ void FlameGraphModel::onModelManagerStateChanged()
|
||||
clear();
|
||||
}
|
||||
|
||||
void FlameGraphModel::restrictToFeatures(quint64 visibleFeatures)
|
||||
{
|
||||
visibleFeatures = visibleFeatures & supportedFeatures();
|
||||
if (visibleFeatures == m_acceptedFeatures)
|
||||
return;
|
||||
|
||||
m_acceptedFeatures = visibleFeatures;
|
||||
if (m_modelManager->state() != QmlProfilerModelManager::Done)
|
||||
return;
|
||||
|
||||
clear();
|
||||
beginResetModel();
|
||||
if (!m_modelManager->replayEvents(m_modelManager->traceTime()->startTime(),
|
||||
m_modelManager->traceTime()->endTime(),
|
||||
std::bind(&FlameGraphModel::loadEvent,
|
||||
this, std::placeholders::_1,
|
||||
std::placeholders::_2))) {
|
||||
emit m_modelManager->error(tr("Could not re-read events from temporary trace file."));
|
||||
endResetModel();
|
||||
clear();
|
||||
} else {
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
|
||||
static QString nameForType(RangeType typeNumber)
|
||||
{
|
||||
switch (typeNumber) {
|
||||
|
||||
Reference in New Issue
Block a user