diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-05-18 16:08:36 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-08 21:48:47 +0000 |
commit | 3df2c4c9920b5136bd99b516dbb803c6316f2259 (patch) | |
tree | 4f11c319ba35666b43cf9b523db38cd72c797de5 /src | |
parent | c5c2ca9e2289a4cfe1072abd737a06bae0de5e4a (diff) |
QListView: add assert for static analyzer
The loop that initializes the item should execute at least once, so the pointer
should be pointing to something valid. The static analyzer doesn't see that,
and warns about unguarded access to the item pointer in report with hash
d008dbef4573afca54be0139e2971a4a. Add asserts for both the condition that makes
the loop run at least once, and for the item pointer not being nullptr.
Change-Id: I94b9f3db3b3ce3d82445cf66788c05854b441aaf
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit ddc886d670694df9e400ea6f04f76df19d0e1145)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/itemviews/qlistview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index a01ab9a86c..fc859f24a2 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -3168,6 +3168,7 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) QRect rect(QPoint(), topLeft); QListViewItem *item = nullptr; + Q_ASSERT(info.first <= info.last); for (int row = info.first; row <= info.last; ++row) { item = &items[row]; if (isHidden(row)) { @@ -3238,6 +3239,7 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) flowPosition += deltaFlowPosition; // current position + item width + gap } } + Q_ASSERT(item); batchSavedDeltaSeg = deltaSegPosition; batchStartRow = info.last + 1; bool done = (info.last >= rowCount() - 1); |