Bug 825992 - Safeguard against null closing AboutHome with a null top sites adapter. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Wed, 02 Jan 2013 11:49:42 -0800
changeset 126443 86204e3d7ce68643c7572d3f0f47be7aa99667e4
parent 126442 0515eda1f932f00bcb9adc1fe51f35eeb77fff36
child 126444 4e18ac9b51e271770fd67b1e8dd5c4eb7d8a4f73
child 126475 7e0ffa0535cc357b7c8377d78e6caf74dde04e49
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs825992
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 825992 - Safeguard against null closing AboutHome with a null top sites adapter. r=mfinkle
mobile/android/base/AboutHomeContent.java
mobile/android/base/db/BrowserDB.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -249,20 +249,21 @@ public class AboutHomeContent extends Sc
     }
 
     public void onDestroy() {
         if (mAccountListener != null) {
             mAccountManager.removeOnAccountsUpdatedListener(mAccountListener);
             mAccountListener = null;
         }
 
-        Cursor cursor = mTopSitesAdapter.getCursor();
-        if (cursor != null && !cursor.isClosed())
-            cursor.close();
-
+        if (mTopSitesAdapter != null) {
+            Cursor cursor = mTopSitesAdapter.getCursor();
+            if (cursor != null && !cursor.isClosed())
+                cursor.close();
+        }
     }
 
     void setLastTabsVisibility(boolean visible) {
         if (visible)
             mLastTabs.show();
         else
             mLastTabs.hide();
     }
--- a/mobile/android/base/db/BrowserDB.java
+++ b/mobile/android/base/db/BrowserDB.java
@@ -310,16 +310,17 @@ public class BrowserDB {
             if (c != null && c.getCount() > 0) {
                 c.moveToPosition(0);
                 do {
                     int pos = c.getInt(c.getColumnIndex(Bookmarks.POSITION));
                     String url = c.getString(c.getColumnIndex(URLColumns.URL));
                     String title = c.getString(c.getColumnIndex(URLColumns.TITLE));
                     mPinnedSites.put(pos, new PinnedSite(title, url));
                 } while (c.moveToNext());
+                c.close();
             }
         }
 
         public boolean hasPinnedSites() {
             return mPinnedSites != null && mPinnedSites.size() > 0;
         }
 
         public PinnedSite getPinnedSite(int position) {