OSDN Git Service

Fixing stack overflow (issue #3270492)
authorAdam Cohen <adamcohen@google.com>
Thu, 9 Dec 2010 19:46:38 +0000 (11:46 -0800)
committerAdam Cohen <adamcohen@google.com>
Thu, 9 Dec 2010 19:47:59 +0000 (11:47 -0800)
Change-Id: I6a9c58d2c0843414fd844c8aa5bf0370da33108b

src/com/android/launcher2/Workspace.java

index b58faed..969fbd7 100644 (file)
@@ -727,8 +727,14 @@ public class Workspace extends SmoothPagedView
         // if shrinkToBottom() is called on initialization, it has to be deferred
         // until after the first call to onLayout so that it has the correct width
         if (mWaitingToShrink) {
-            shrink(mWaitingToShrinkState, false);
-            mWaitingToShrink = false;
+            // shrink can trigger a synchronous onLayout call, so we
+            // post this to avoid a stack overflow / tangled onLayout calls
+            post(new Runnable() {
+                public void run() {
+                    shrink(mWaitingToShrinkState, false);
+                    mWaitingToShrink = false;
+                }
+            });
         }
 
         if (LauncherApplication.isInPlaceRotationEnabled()) {
@@ -753,7 +759,6 @@ public class Workspace extends SmoothPagedView
                 mCustomizeTrayBackground.draw(canvas);
             }
         }
-
         super.onDraw(canvas);
     }