Bug 697528 - Fix NPE when history is empty (r=lucasr)

If the history is empty, then some data structures don't get initialized and
this results in an NPE. Ensure that the data structures wherever used, and do
an early exit so we don't uselessly run code when the history is empty.
This commit is contained in:
Kartikaya Gupta 2011-10-27 09:49:29 -04:00
parent b6e982b925
commit 7436980605

View File

@ -294,14 +294,14 @@ public class AwesomeBarTabs extends TabHost {
long time = cursor.getLong(cursor.getColumnIndexOrThrow(Browser.BookmarkColumns.DATE));
HistorySection itemSection = getSectionForTime(time, today);
if (groups == null)
groups = new LinkedList<Map<String,?>>();
if (childrenLists == null)
childrenLists = new LinkedList<List<Map<String,?>>>();
if (section != itemSection) {
if (section != null) {
if (groups == null)
groups = new LinkedList<Map<String,?>>();
if (childrenLists == null)
childrenLists = new LinkedList<List<Map<String,?>>>();
groups.add(createGroupItem(section));
childrenLists.add(children);
}
@ -323,6 +323,10 @@ public class AwesomeBarTabs extends TabHost {
// Close the query cursor as we won't use it anymore
cursor.close();
// FIXME: display some sort of message when there's no history
if (groups == null)
return;
mHistoryAdapter = new HistoryListAdapter(
mContext,
groups,