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 <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-08-27 13:48:25 +02:00
parent dc6c0bceac
commit 00650c8b65
3 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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();