OSDN Git Service

Prevent an IllegalStateException.
authorLeon Scroggins III <scroggo@google.com>
Tue, 30 Mar 2010 15:24:14 +0000 (11:24 -0400)
committerLeon Scroggins III <scroggo@google.com>
Tue, 30 Mar 2010 15:54:22 +0000 (11:54 -0400)
Also add Log statements to help determine the root problem.

Fix for http://b/issue?id=2532489

Change-Id: I90e6e4b4a1d0602a5baf3362b732e73d47cc49bf

src/com/android/browser/Tab.java

index 07b17a9..8c2371a 100644 (file)
@@ -1506,8 +1506,30 @@ class Tab {
         // container to the content view.
         FrameLayout wrapper =
                 (FrameLayout) mContainer.findViewById(R.id.webview_wrapper);
-        wrapper.addView(mMainView);
-        content.addView(mContainer, BrowserActivity.COVER_SCREEN_PARAMS);
+        ViewGroup parent = (ViewGroup) mMainView.getParent();
+        if (parent != wrapper) {
+            if (parent != null) {
+                Log.w(LOGTAG, "mMainView already has a parent in"
+                        + " attachTabToContentView!");
+                parent.removeView(mMainView);
+            }
+            wrapper.addView(mMainView);
+        } else {
+            Log.w(LOGTAG, "mMainView is already attached to wrapper in"
+                    + " attachTabToContentView!");
+        }
+        parent = (ViewGroup) mContainer.getParent();
+        if (parent != content) {
+            if (parent != null) {
+                Log.w(LOGTAG, "mContainer already has a parent in"
+                        + " attachTabToContentView!");
+                parent.removeView(mContainer);
+            }
+            content.addView(mContainer, BrowserActivity.COVER_SCREEN_PARAMS);
+        } else {
+            Log.w(LOGTAG, "mContainer is already attached to content in"
+                    + " attachTabToContentView!");
+        }
         attachSubWindow(content);
     }