diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-04-12 17:23:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-17 16:28:46 +0200 |
commit | 7c3684dff72eb62257ce6f50ec2b9c36fb2c8a21 (patch) | |
tree | 57f315403b58247984de84ce64c6a84e454bcee2 /src/widgets | |
parent | 576a8e152ec36e7465bfdc8ad63998cffbab4091 (diff) |
Fix out of bounds use of QVector API.
This is a regression introduced by commit
22b7d211865c1505862627a2e65bcd063e314e45.
Task-number: QTBUG-24965
Task-number: QTBUG-25140
Change-Id: I3f3bfe23af802444b078a29ee5565dd2bd24a34d
Reviewed-by: David Faure <faure@kde.org>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 11 | ||||
-rw-r--r-- | src/widgets/itemviews/qtreeview_p.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index be78cdbf14..aaec2b1346 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1390,7 +1390,10 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index. QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only. - calcLogicalIndices(&logicalIndices, &viewItemPosList); + const bool spanning = viewItems.at(row).spanning; + const int left = (spanning ? header->visualIndex(0) : 0); + const int right = (spanning ? header->visualIndex(0) : header->count() - 1 ); + calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); int columnIndex = 0; for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) { @@ -1488,10 +1491,8 @@ static inline bool ancestorOf(QObject *widget, QObject *other) return false; } -void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const +void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions, int left, int right) const { - const int left = (spanning ? header->visualIndex(0) : leftAndRight.first); - const int right = (spanning ? header->visualIndex(0) : leftAndRight.second); const int columnCount = header->count(); /* 'left' and 'right' are the left-most and right-most visible visual indices. Compute the first visible logical indices before and after the left and right. @@ -1615,7 +1616,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, QVector<int> logicalIndices; QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex - d->calcLogicalIndices(&logicalIndices, &viewItemPosList); + d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) { int headerSection = logicalIndices.at(currentLogicalSection); diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index c8fb8853a6..091420e49e 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -170,7 +170,7 @@ public: // logicalIndices: vector of currently visibly logical indices // itemPositions: vector of view item positions (beginning/middle/end/onlyone) - void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const; + void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions, int left, int right) const; QHeaderView *header; int indent; |