forked from qt-creator/qt-creator
Fix PixmapCacheModel to not get confused on plain LoadingFinished
The indices SortedTimelineModel returns are only valid until you insert something at a different place than the end. If you do that, all later events are shifted by one. We can "fix" that by also shifting the saved indices. Change-Id: I63180dabea0c52db55e799b023b3f2bf84f9e59a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -456,6 +456,21 @@ void PixmapCacheModel::loadData()
|
|||||||
if (state.loadState == Initial) {
|
if (state.loadState == Initial) {
|
||||||
newEvent.pixmapEventType = PixmapLoadingStarted;
|
newEvent.pixmapEventType = PixmapLoadingStarted;
|
||||||
state.started = d->insert(traceStartTime(), startTime - traceStartTime(), newEvent);
|
state.started = d->insert(traceStartTime(), startTime - traceStartTime(), newEvent);
|
||||||
|
|
||||||
|
// All other indices are wrong now as we've prepended. Fix them ...
|
||||||
|
if (lastCacheSizeEvent >= state.started)
|
||||||
|
++lastCacheSizeEvent;
|
||||||
|
|
||||||
|
for (int pixmapIndex = 0; pixmapIndex < d->pixmaps.count(); ++pixmapIndex) {
|
||||||
|
Pixmap &brokenPixmap = d->pixmaps[pixmapIndex];
|
||||||
|
for (int sizeIndex = 0; sizeIndex < brokenPixmap.sizes.count(); ++sizeIndex) {
|
||||||
|
PixmapState &brokenSize = brokenPixmap.sizes[sizeIndex];
|
||||||
|
if ((pixmapIndex != newEvent.urlIndex || sizeIndex != newEvent.sizeIndex) &&
|
||||||
|
brokenSize.started >= state.started) {
|
||||||
|
++brokenSize.started;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->insertEnd(state.started, startTime - d->range(state.started).start);
|
d->insertEnd(state.started, startTime - d->range(state.started).start);
|
||||||
|
Reference in New Issue
Block a user