From 00650c8b65633b40b5a650436d4062ad288b4a5a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 27 Aug 2014 13:48:25 +0200 Subject: [PATCH] QmlProfiler: connect category labels to specific models By listening only to the relevant expandedChanged and rowHeightChanged signals we avoid accessing invalid data on clearing. When clearing the models each one is collapsed. The collapsing in turn triggers rebuilding of the labels. Unrelated labels could access already cleared data like this. Change-Id: I3fad45f5c6279019fbc27ec54e758f498a9d55f2 Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/CategoryLabel.qml | 8 ++++++-- src/plugins/qmlprofiler/timelinemodelaggregator.cpp | 9 +++++++++ src/plugins/qmlprofiler/timelinemodelaggregator.h | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmlprofiler/qml/CategoryLabel.qml b/src/plugins/qmlprofiler/qml/CategoryLabel.qml index a84cddca5e2..fd66dfc2f6f 100644 --- a/src/plugins/qmlprofiler/qml/CategoryLabel.qml +++ b/src/plugins/qmlprofiler/qml/CategoryLabel.qml @@ -75,12 +75,16 @@ Item { } Connections { - target: qmlProfilerModelProxy + target: qmlProfilerModelProxy.models[modelIndex] onExpandedChanged: updateDescriptions() - onStateChanged: updateDescriptions() onRowHeightChanged: updateDescriptions() } + Connections { + target: qmlProfilerModelProxy + onStateChanged: updateDescriptions() + } + Text { id: txt x: 5 diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp index f9776b77456..e6c582854ae 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -92,6 +92,15 @@ void TimelineModelAggregator::addModel(AbstractTimelineModel *m) d->modelList << m; connect(m,SIGNAL(expandedChanged()),this,SIGNAL(expandedChanged())); connect(m,SIGNAL(rowHeightChanged()),this,SIGNAL(rowHeightChanged())); + emit modelsChanged(); +} + +QVariantList TimelineModelAggregator::models() const +{ + QVariantList ret; + foreach (AbstractTimelineModel *model, d->modelList) + ret << QVariant::fromValue(model); + return ret; } int TimelineModelAggregator::count(int modelIndex) const diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.h b/src/plugins/qmlprofiler/timelinemodelaggregator.h index b04962af561..ef60cfd631e 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.h @@ -39,12 +39,14 @@ namespace Internal { class TimelineModelAggregator : public QObject { Q_OBJECT + Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged) public: TimelineModelAggregator(QObject *parent = 0); ~TimelineModelAggregator(); void setModelManager(QmlProfilerModelManager *modelManager); void addModel(AbstractTimelineModel *m); + QVariantList models() const; Q_INVOKABLE int count(int modelIndex = -1) const; void clear(); @@ -94,6 +96,7 @@ signals: void stateChanged(); void expandedChanged(); void rowHeightChanged(); + void modelsChanged(); protected slots: void dataChanged();