Bug 1039471 - Only restart loader if RecentTabsPanel is still attached (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 17 Jul 2014 11:36:46 +0100
changeset 216569 12a593a3681d9f47dc5af308e7ec70f270be8672
parent 216568 c1d47fd0303204463cd1288699f076359dff4a9c
child 216570 47b760a88f04cd4edeff7860f6d911ef3ab6d069
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1039471
milestone33.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 1039471 - Only restart loader if RecentTabsPanel is still attached (r=margaret)
mobile/android/base/home/RecentTabsPanel.java
--- a/mobile/android/base/home/RecentTabsPanel.java
+++ b/mobile/android/base/home/RecentTabsPanel.java
@@ -244,18 +244,22 @@ public class RecentTabsPanel extends Hom
         }
 
         // Only modify mClosedTabs on the UI thread
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 mClosedTabs = closedTabs;
 
-                // Reload the cursor to show recently closed tabs.
-                getLoaderManager().restartLoader(LOADER_ID_RECENT_TABS, null, mCursorLoaderCallbacks);
+                // The fragment might have been detached before this code
+                // runs in the UI thread.
+                if (getActivity() != null) {
+                    // Reload the cursor to show recently closed tabs.
+                    getLoaderManager().restartLoader(LOADER_ID_RECENT_TABS, null, mCursorLoaderCallbacks);
+                }
             }
         });
     }
 
     private void openTabsWithType(int type) {
         final Cursor c = mAdapter.getCursor();
         if (c == null || !c.moveToFirst()) {
             return;