Bug 519478 - UMR in nsAutoCompleteController::ClosePopup. r=gavin.sharp
authorJustin Dolske <dolske@mozilla.com>
Sun, 04 Oct 2009 23:46:25 -0700
changeset 33455 c75a0852ea72831d1d1c72df3d190ea31788ad48
parent 33454 08280b7f6982554b9bebc404472cc5d67fb4eefc
child 33456 1470fa9c9f0189295cba7d108ba46f9c4e36e3b1
push idunknown
push userunknown
push dateunknown
reviewersgavin.sharp
bugs519478
milestone1.9.3a1pre
Bug 519478 - UMR in nsAutoCompleteController::ClosePopup. r=gavin.sharp
toolkit/components/autocomplete/src/nsAutoCompleteController.cpp
toolkit/components/satchel/src/nsFormFillController.cpp
--- a/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp
+++ b/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp
@@ -323,17 +323,17 @@ nsAutoCompleteController::HandleStartCom
   PRBool disabled;
   input->GetDisableAutoComplete(&disabled);
   if (disabled)
     return NS_OK;
 
   // Stop all searches in case they are async.
   StopSearch();
 
-  PRBool isOpen;
+  PRBool isOpen = PR_FALSE;
   input->GetPopupOpen(&isOpen);
   if (isOpen)
     ClosePopup();
   mPopupClosedByCompositionStart = isOpen;
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -399,17 +399,17 @@ nsAutoCompleteController::HandleKeyNavig
       aKey == nsIDOMKeyEvent::DOM_VK_DOWN ||
       aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ||
       aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN)
   {
     // Prevent the input from handling up/down events, as it may move
     // the cursor to home/end on some systems
     *_retval = PR_TRUE;
 
-    PRBool isOpen;
+    PRBool isOpen = PR_FALSE;
     input->GetPopupOpen(&isOpen);
     if (isOpen) {
       PRBool reverse = aKey == nsIDOMKeyEvent::DOM_VK_UP ||
                       aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ? PR_TRUE : PR_FALSE;
       PRBool page = aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ||
                     aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN ? PR_TRUE : PR_FALSE;
 
       // Fill in the value of the textbox with whatever is selected in the popup
@@ -473,17 +473,17 @@ nsAutoCompleteController::HandleKeyNavig
   } else if (   aKey == nsIDOMKeyEvent::DOM_VK_LEFT
              || aKey == nsIDOMKeyEvent::DOM_VK_RIGHT
 #ifndef XP_MACOSX
              || aKey == nsIDOMKeyEvent::DOM_VK_HOME
 #endif
             )
   {
     // The user hit a text-navigation key.
-    PRBool isOpen;
+    PRBool isOpen = PR_FALSE;
     input->GetPopupOpen(&isOpen);
     if (isOpen) {
       PRInt32 selectedIndex;
       popup->GetSelectedIndex(&selectedIndex);
       PRBool shouldComplete;
       input->GetCompleteDefaultIndex(&shouldComplete);
       if (selectedIndex >= 0) {
         // The pop-up is open and has a selection, take its value
@@ -944,17 +944,17 @@ nsAutoCompleteController::OpenPopup()
 
 nsresult
 nsAutoCompleteController::ClosePopup()
 {
   if (!mInput) {
     return NS_OK;
   }
 
-  PRBool isOpen;
+  PRBool isOpen = PR_FALSE;
   mInput->GetPopupOpen(&isOpen);
   if (!isOpen)
     return NS_OK;
 
   nsCOMPtr<nsIAutoCompletePopup> popup;
   mInput->GetPopup(getter_AddRefs(popup));
   NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
   popup->SetSelectedIndex(-1);
--- a/toolkit/components/satchel/src/nsFormFillController.cpp
+++ b/toolkit/components/satchel/src/nsFormFillController.cpp
@@ -194,16 +194,18 @@ nsFormFillController::GetController(nsIA
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFormFillController::GetPopupOpen(PRBool *aPopupOpen)
 {
   if (mFocusedPopup)
     mFocusedPopup->GetPopupOpen(aPopupOpen);
+  else
+    *aPopupOpen = PR_FALSE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFormFillController::SetPopupOpen(PRBool aPopupOpen)
 {
   if (mFocusedPopup) {
     if (aPopupOpen) {