From dd8f7f450f203d733621c79209fdc879254502e5 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 12 Oct 2005 23:03:58 +0000 Subject: [PATCH] Attempt to fix crashes using arrow-key scrolling in autocomplete. Bug 306067, r+sr=dbaron. --- .../autocomplete/src/nsAutoCompleteController.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp index 953bdbedb5f8..896104203915 100644 --- a/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp @@ -391,13 +391,15 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval) PRBool page = aKey == nsIAutoCompleteController::KEY_PAGE_UP || aKey == nsIAutoCompleteController::KEY_PAGE_DOWN ? PR_TRUE : PR_FALSE; + // Fill in the value of the textbox with whatever is selected in the popup + // if the completeSelectedIndex attribute is set. We check this before + // calling SelectBy since that can null out mInput in some cases. + PRBool completeSelection; + mInput->GetCompleteSelectedIndex(&completeSelection); + // Instruct the result view to scroll by the given amount and direction popup->SelectBy(reverse, page); - // Fill in the value of the textbox with whatever is selected in the popup - // if the completeSelectedIndex attribute is set - PRBool completeSelection; - mInput->GetCompleteSelectedIndex(&completeSelection); if (completeSelection) { PRInt32 selectedIndex;