Skip to content

Commit 61af8a8

Browse files
author
Dianne Hackborn
committed
Working on issue #6561352: java.lang.RuntimeException: Unable to start...
...activity ComponentInfo{com.google.android.googlequicksearchbox /com.google.android.googlequicksearchbox.SearchActivity} Add check for a situation where we are saving the state of a fragment with a -1 index, and fail early in that case with more debug information. Change-Id: I03a928dde521fa06664d0036dd9f90eef3247afc
1 parent 3c144c3 commit 61af8a8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

core/java/android/app/FragmentManager.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,17 @@ Parcelable saveAllState() {
15681568
for (int i=0; i<N; i++) {
15691569
Fragment f = mActive.get(i);
15701570
if (f != null) {
1571+
if (f.mIndex < 0) {
1572+
String msg = "Failure saving state: active " + f
1573+
+ " has cleared index: " + f.mIndex;
1574+
Slog.e(TAG, msg);
1575+
dump(" ", null, new PrintWriter(new LogWriter(
1576+
Log.ERROR, TAG, Log.LOG_ID_SYSTEM)), new String[] { });
1577+
throw new IllegalStateException(msg);
1578+
}
1579+
15711580
haveFragments = true;
1572-
1581+
15731582
FragmentState fs = new FragmentState(f);
15741583
active[i] = fs;
15751584

@@ -1621,6 +1630,14 @@ Parcelable saveAllState() {
16211630
added = new int[N];
16221631
for (int i=0; i<N; i++) {
16231632
added[i] = mAdded.get(i).mIndex;
1633+
if (added[i] < 0) {
1634+
String msg = "Failure saving state: active " + mAdded.get(i)
1635+
+ " has cleared index: " + added[i];
1636+
Slog.e(TAG, msg);
1637+
dump(" ", null, new PrintWriter(new LogWriter(
1638+
Log.ERROR, TAG, Log.LOG_ID_SYSTEM)), new String[] { });
1639+
throw new IllegalStateException(msg);
1640+
}
16241641
if (DEBUG) Log.v(TAG, "saveAllState: adding fragment #" + i
16251642
+ ": " + mAdded.get(i));
16261643
}

0 commit comments

Comments
 (0)