From a8961119960614433a9edb0b8eb5bcc54748aee7 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 27 Oct 2011 09:49:29 -0400 Subject: [PATCH] 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. --- embedding/android/AwesomeBarTabs.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/embedding/android/AwesomeBarTabs.java b/embedding/android/AwesomeBarTabs.java index e70f51baf178..27acf872d9c8 100644 --- a/embedding/android/AwesomeBarTabs.java +++ b/embedding/android/AwesomeBarTabs.java @@ -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>(); + + if (childrenLists == null) + childrenLists = new LinkedList>>(); + if (section != itemSection) { if (section != null) { - if (groups == null) - groups = new LinkedList>(); - - if (childrenLists == null) - childrenLists = new LinkedList>>(); - 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,