diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-01-26 10:00:18 -0800 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-05-06 13:21:33 -0700 |
commit | 44bfdd88a74d5935a011bc8671cb075f2047655b (patch) | |
tree | 0bb610d5dc93b118d0afcc0e97c8ec5490e3f760 /core/java/android/app | |
parent | 3fd4a3822160e8ad84122641a56c9f92540d02b5 (diff) | |
download | frameworks_base-44bfdd88a74d5935a011bc8671cb075f2047655b.zip frameworks_base-44bfdd88a74d5935a011bc8671cb075f2047655b.tar.gz frameworks_base-44bfdd88a74d5935a011bc8671cb075f2047655b.tar.bz2 |
Dialog not dismissed when tearing down dialog fragment.
1. The dismiss implementaton in Dialog was posting a message
on the main thread to perform the real dismiss work. The
goal of this was to allow calling dismiss() from multiple
threads. The side effect of this is that when dialog fragment
is dismissed the dialog is not dimissed until the current
loop on the main thread is completed. However, during rotation
of the screen the current activity has to be restarted, hence
all fragments whould be removed. In the destruction process
the dialog grament requests from the dialog to dismiss but
since this is asynchromous, the code in
ActivityThread#handleDestroyActivity detects a leaking window
since the dialog window is still not removed and removes that
window. Now when the dialog removal message is processed on
the next loop we get an exception that the window has already
been removed. Now if Dialog#dismiss() is called from the
main thread the call goes right though otherwise a message is
posted.
bug:5911682
Change-Id: I449d6dd75a84c0ff29ea13dac7d163219cc38341
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/Dialog.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 4a5b8eb..2cc3b02 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -27,6 +27,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.util.Log; import android.util.TypedValue; @@ -297,7 +298,11 @@ public class Dialog implements DialogInterface, Window.Callback, * that in {@link #onStop}. */ public void dismiss() { - mHandler.post(mDismissAction); + if (Looper.myLooper() == mHandler.getLooper()) { + dismissDialog(); + } else { + mHandler.post(mDismissAction); + } } void dismissDialog() { |