diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-10-28 14:10:36 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-10-28 15:00:02 (GMT) |
commit | d560894ad085ac8c6266fd1af66139db950f473f (patch) | |
tree | 1b74d63950a7c1accc2c0c97b8de105b637f65e7 /src/gui/itemviews | |
parent | 6e228d57da9d5dd9b7365d5539f6ed88cafb5d97 (diff) | |
download | Qt-d560894ad085ac8c6266fd1af66139db950f473f.zip Qt-d560894ad085ac8c6266fd1af66139db950f473f.tar.gz Qt-d560894ad085ac8c6266fd1af66139db950f473f.tar.bz2 |
Fixed bug in QTableView spans.
In some cases, the spans internal structure was left in an inconsistent
state. Auto-test included. Bonus: spans consistency checking method.
Task-number: QTBUG-5062
Reviewed-by: Olivier
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qtableview.cpp | 43 | ||||
-rw-r--r-- | src/gui/itemviews/qtableview_p.h | 6 |
2 files changed, 47 insertions, 2 deletions
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index c80faa2..02e5fff 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -117,7 +117,7 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) Index::iterator it_y = index.lowerBound(-span->bottom()); Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list while (-it_y.key() <= span->top() + old_height -1) { - if(-it_y.key() != span->bottom()) { + if (-it_y.key() > span->bottom()) { (*it_y).remove(-span->left()); if (it_y->isEmpty()) { it_y = index.erase(it_y) - 1; @@ -544,6 +544,47 @@ void QSpanCollection::updateRemovedColumns(int start, int end) qDeleteAll(toBeDeleted); } +#ifdef QT_BUILD_INTERNAL +/*! + \internal + Checks whether the span index structure is self-consistent, and consistent with the spans list. +*/ +bool QSpanCollection::checkConsistency() const +{ + for (Index::const_iterator it_y = index.begin(); it_y != index.end(); ++it_y) { + int y = -it_y.key(); + const SubIndex &subIndex = it_y.value(); + for (SubIndex::const_iterator it = subIndex.begin(); it != subIndex.end(); ++it) { + int x = -it.key(); + Span *span = it.value(); + if (!spans.contains(span) || span->left() != x + || y < span->top() || y > span->bottom()) + return false; + } + } + + foreach (const Span *span, spans) { + if (span->width() < 1 || span->height() < 1 + || (span->width() == 1 && span->height() == 1)) + return false; + for (int y = span->top(); y <= span->bottom(); ++y) { + Index::const_iterator it_y = index.find(-y); + if (it_y == index.end()) { + if (y == span->top()) + return false; + else + continue; + } + const SubIndex &subIndex = it_y.value(); + SubIndex::const_iterator it = subIndex.find(-span->left()); + if (it == subIndex.end() || it.value() != span) + return false; + } + } + return true; +} +#endif + class QTableCornerButton : public QAbstractButton { Q_OBJECT diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h index 9fa14c2..6b19ded 100644 --- a/src/gui/itemviews/qtableview_p.h +++ b/src/gui/itemviews/qtableview_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE * The key of the first map is the row where the subspan starts, the value of the first map is * a list (map) of all subspans that starts at the same row. It is indexed with its row */ -class QSpanCollection +class Q_AUTOTEST_EXPORT QSpanCollection { public: struct Span @@ -112,6 +112,10 @@ public: void updateRemovedRows(int start, int end); void updateRemovedColumns(int start, int end); +#ifdef QT_BUILD_INTERNAL + bool checkConsistency() const; +#endif + typedef QLinkedList<Span *> SpanList; SpanList spans; //lists of all spans private: |