Clear child FragmentManagers when destroying Fragments.

If Fragment has instantiated a child FragmentManager and is later
detached, it retains its reference to the child FragmentManager which
has been destroyed. This causes an IllegalStateException in the
child FragmentManager if the original Fragment is reattached.

Fixes Issue 42601.

Change-Id: I8db2b1a110a341dc259939723f4c5ec131ca5f1e
This commit is contained in:
Tim Kilbourn
2014-02-28 01:00:06 -08:00
parent 4c7e6900c8
commit 7071786e00
2 changed files with 2 additions and 0 deletions

View File

@@ -1402,6 +1402,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mRestored = false;
mBackStackNesting = 0;
mFragmentManager = null;
mChildFragmentManager = null;
mActivity = null;
mFragmentId = 0;
mContainerId = 0;

View File

@@ -1026,6 +1026,7 @@ final class FragmentManagerImpl extends FragmentManager {
f.mActivity = null;
f.mParentFragment = null;
f.mFragmentManager = null;
f.mChildFragmentManager = null;
}
}
}