Bug 1356693 - Pre: add comment explaining why MergeCursor can't handle null cursors r=Grisha

MozReview-Commit-ID: CGwMi9LKYTj

--HG--
extra : rebase_source : 3271350e1fc7cd972feb1dbd6fa733c834342d94
This commit is contained in:
Andrzej Hunt 2017-04-28 08:38:41 +08:00
Родитель e8919657c8
Коммит 0e1b1383b2
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -297,7 +297,11 @@ public class BookmarksPanel extends HomeFragment implements BookmarkEditFragment
userCursor = mDB.getBookmarksInFolder(contentResolver, mFolderInfo.id);
}
// MergeCursor is only partly capable of handling null cursors, hence the complicated
// logic here. The main issue is CursorAdapter always queries the _id column when
// swapping a cursor. If you haven't started iterating over the cursor, MergeCursor will
// try to fetch columns from the first Cursor in the list - if that item is null,
// we can't getColumnIndexOrThrow("_id"), and CursorAdapter crashes.
if (partnerCursor == null && userCursor == null) {
return null;
} else if (partnerCursor == null) {
@ -305,8 +309,10 @@ public class BookmarksPanel extends HomeFragment implements BookmarkEditFragment
} else if (userCursor == null) {
return partnerCursor;
} else {
return new MergeCursor(new Cursor[] { partnerCursor, userCursor });
return new MergeCursor(new Cursor[]{ partnerCursor, userCursor });
}
}
@Override