forked from qt-creator/qt-creator
		
	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:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user