Skip to content

Commit 06f938e

Browse files
committed
PopupWindow dismiss() can get into a recursive loop.
1. The dismiss method in a PopupWindow is first removing the popup View from the WindowManager and then if the content View differs from the popup View the former is removed from the latter. Then dismiss() clears the dismissed flag so a subsequent call to dismiss() is a NOP. However, removing a View both from the WindowManager and from its parent ViewGroup triggers stuff wich may lead to a subsequent call to dismiss(). This leads to a stack overflow exception. bug:5598944 Change-Id: I2aeeda591be3e9aa98fec1ee17ea8f0e746e6992
1 parent e562287 commit 06f938e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/java/android/widget/PopupWindow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,8 @@ public int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomD
12481248
*/
12491249
public void dismiss() {
12501250
if (isShowing() && mPopupView != null) {
1251+
mIsShowing = false;
1252+
12511253
unregisterForScrollChanged();
12521254

12531255
try {
@@ -1257,7 +1259,6 @@ public void dismiss() {
12571259
((ViewGroup) mPopupView).removeView(mContentView);
12581260
}
12591261
mPopupView = null;
1260-
mIsShowing = false;
12611262

12621263
if (mOnDismissListener != null) {
12631264
mOnDismissListener.onDismiss();

0 commit comments

Comments
 (0)