Skip to content

Commit 0f938d5

Browse files
committed
secure loading thumbrange on empty list
mention in #28
1 parent 64aefc7 commit 0f938d5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ThumbsViewer.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -1201,30 +1201,37 @@ void ThumbsViewer::scanForSort(UserRoles role) {
12011201

12021202
void ThumbsViewer::loadThumbsRange() {
12031203
static bool isInProgress = false;
1204-
static int currentRowCount;
1205-
int currThumb;
12061204

12071205
if (isInProgress) {
12081206
isAbortThumbsLoading = true;
12091207
QTimer::singleShot(0, this, SLOT(loadThumbsRange()));
12101208
return;
12111209
}
12121210

1211+
int currentRowCount = m_model->rowCount();
1212+
if (!currentRowCount)
1213+
return;
1214+
12131215
isInProgress = true;
1214-
currentRowCount = m_model->rowCount();
12151216

12161217
QElapsedTimer timer;
12171218
timer.start();
12181219

12191220
for (bool fastOnly : { true, false }) {
1221+
int currThumb;
12201222
for (scrolledForward ? currThumb = thumbsRangeFirst : currThumb = thumbsRangeLast;
12211223
(scrolledForward ? currThumb <= thumbsRangeLast : currThumb >= thumbsRangeFirst);
12221224
scrolledForward ? ++currThumb : --currThumb) {
12231225

12241226
if (isAbortThumbsLoading || m_model->rowCount() != currentRowCount || currThumb < 0)
12251227
break;
12261228

1227-
if (m_model->item(currThumb)->data(LoadedRole).toBool())
1229+
QStandardItem *item = m_model->item(currThumb);
1230+
if (!item) {
1231+
qDebug() << "meek" << m_model->rowCount() << currentRowCount << currThumb << thumbsRangeFirst << thumbsRangeLast << scrolledForward;
1232+
continue;
1233+
}
1234+
if (item->data(LoadedRole).toBool())
12281235
continue;
12291236

12301237
loadThumb(currThumb, fastOnly);

0 commit comments

Comments
 (0)