@@ -308,6 +308,10 @@ public class WebView extends AbsoluteLayout
308308 // true means redraw the screen all-the-time. Only with AUTO_REDRAW_HACK
309309 private boolean mAutoRedraw ;
310310
311+ // Reference to the AlertDialog displayed by InvokeListBox.
312+ // It's used to dismiss the dialog in destroy if not done before.
313+ private AlertDialog mListBoxDialog = null ;
314+
311315 static final String LOGTAG = "webview" ;
312316
313317 private static class ExtendedZoomControls extends FrameLayout {
@@ -1232,6 +1236,10 @@ public String[] getHttpAuthUsernamePassword(String host, String realm) {
12321236 */
12331237 public void destroy () {
12341238 clearTextEntry (false );
1239+ if (mListBoxDialog != null ) {
1240+ mListBoxDialog .dismiss ();
1241+ mListBoxDialog = null ;
1242+ }
12351243 if (mWebViewCore != null ) {
12361244 // Set the handlers to null before destroying WebViewCore so no
12371245 // more messages will be posted.
@@ -7072,7 +7080,7 @@ public void onClick(DialogInterface dialog, int which) {
70727080 EventHub .SINGLE_LISTBOX_CHOICE , -2 , 0 );
70737081 }});
70747082 }
7075- final AlertDialog dialog = b .create ();
7083+ mListBoxDialog = b .create ();
70767084 listView .setAdapter (adapter );
70777085 listView .setFocusableInTouchMode (true );
70787086 // There is a bug (1250103) where the checks in a ListView with
@@ -7094,7 +7102,8 @@ public void onItemClick(AdapterView parent, View v,
70947102 int position , long id ) {
70957103 mWebViewCore .sendMessage (
70967104 EventHub .SINGLE_LISTBOX_CHOICE , (int )id , 0 );
7097- dialog .dismiss ();
7105+ mListBoxDialog .dismiss ();
7106+ mListBoxDialog = null ;
70987107 }
70997108 });
71007109 if (mSelection != -1 ) {
@@ -7106,13 +7115,14 @@ public void onItemClick(AdapterView parent, View v,
71067115 adapter .registerDataSetObserver (observer );
71077116 }
71087117 }
7109- dialog .setOnCancelListener (new DialogInterface .OnCancelListener () {
7118+ mListBoxDialog .setOnCancelListener (new DialogInterface .OnCancelListener () {
71107119 public void onCancel (DialogInterface dialog ) {
71117120 mWebViewCore .sendMessage (
71127121 EventHub .SINGLE_LISTBOX_CHOICE , -2 , 0 );
7122+ mListBoxDialog = null ;
71137123 }
71147124 });
7115- dialog .show ();
7125+ mListBoxDialog .show ();
71167126 }
71177127 }
71187128
0 commit comments