diff options
author | 2017-02-02 07:22:50 -0800 | |
---|---|---|
committer | 2017-02-03 08:11:44 -0800 | |
commit | 8c4fa3615dbc09a838f1a341e19c0d0e543f6150 (patch) | |
tree | 2f7234e5926eb249a2ebfd102728e451c847ab89 | |
parent | 6ba95dab4210cd7ce6ee85393fd3c8595faed8c4 (diff) |
Fix: fragment destroyed improperly during pop.
Bug 34850219
When multiple back stack records were popped together,
to the bottom of the stack, the fragment at the bottom
would be destroyed. This was caused by the back stack
being bumped prior to executing the operations. The
back stack record index didn't properly reflect the
state it should be in during the operation and the
final fragment returned false to isInBackStack().
This CL moves the back stack bumping to immediately
prior to executing the operations.
Test: I887d565d245cd61434963040c20f887a10bf51dc
Change-Id: I3ad2be65cf0e66bf5615c0e912cc233528ee72a3
-rw-r--r-- | core/java/android/app/FragmentManager.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 4f68ec71c5dd..b7c0737487ca 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -2077,8 +2077,6 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate } else { record.trackAddedFragmentsInPop(mTmpAddedFragments); } - final int bumpAmount = isPop ? -1 : 1; - record.bumpBackStackNesting(bumpAmount); addToBackStack = addToBackStack || record.mAddToBackStack; } mTmpAddedFragments.clear(); @@ -2281,8 +2279,10 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate final BackStackRecord record = records.get(i); final boolean isPop = isRecordPop.get(i); if (isPop) { + record.bumpBackStackNesting(-1); record.executePopOps(); } else { + record.bumpBackStackNesting(1); record.executeOps(); } } |