Skip to content

Commit 7a5a50c

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Bug 5513073 - IllegalArgumentException: View not attached to window manager" into ics-mr1
2 parents e5d0f19 + 89fc3ac commit 7a5a50c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/java/android/app/Dialog.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import android.os.Bundle;
2929
import android.os.Handler;
3030
import android.os.Message;
31+
import android.util.Log;
3132
import android.util.TypedValue;
3233
import android.view.ActionMode;
3334
import android.view.ContextMenu;
@@ -77,6 +78,7 @@
7778
*/
7879
public class Dialog implements DialogInterface, Window.Callback,
7980
KeyEvent.Callback, OnCreateContextMenuListener {
81+
private static final String TAG = "Dialog";
8082
private Activity mOwnerActivity;
8183

8284
final Context mContext;
@@ -300,15 +302,21 @@ public void dismiss() {
300302
if (Thread.currentThread() != mUiThread) {
301303
mHandler.post(mDismissAction);
302304
} else {
305+
mHandler.removeCallbacks(mDismissAction);
303306
mDismissAction.run();
304307
}
305308
}
306309

307-
private void dismissDialog() {
310+
void dismissDialog() {
308311
if (mDecor == null || !mShowing) {
309312
return;
310313
}
311314

315+
if (mWindow.isDestroyed()) {
316+
Log.e(TAG, "Tried to dismissDialog() but the Dialog's window was already destroyed!");
317+
return;
318+
}
319+
312320
try {
313321
mWindowManager.removeView(mDecor);
314322
} finally {

0 commit comments

Comments
 (0)