Bug 1202583 - crash in java.lang.NullPointerException: Attempt to read from field ''java.lang.String org.mozilla.gecko.home.SearchEngine.name'' on a null object reference.r=mfinkle
authorAllison Naaktgeboren <ally@mozilla.com>
Sun, 13 Sep 2015 13:13:43 -0700
changeset 294847 b185d4bce7d91958696be9c750ac43252dfa23b0
parent 294839 9ed17db42e3e46f1c712e4dffd62d54e915e0fac
child 294848 00693818cbf5fdd073dd4d895be44771091e9432
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1202583
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202583 - crash in java.lang.NullPointerException: Attempt to read from field ''java.lang.String org.mozilla.gecko.home.SearchEngine.name'' on a null object reference.r=mfinkle
mobile/android/base/home/SearchEngineRow.java
--- a/mobile/android/base/home/SearchEngineRow.java
+++ b/mobile/android/base/home/SearchEngineRow.java
@@ -156,17 +156,17 @@ class SearchEngineRow extends AnimatedHe
             mSearchListener.onSearch(mSearchEngine, searchTerm);
         }
     }
 
     public void setSearchTerm(String searchTerm) {
         mUserEnteredTextView.setText(searchTerm);
 
         // mSearchEngine is not set in the first call to this method; the content description
-        // is instead initially set in updateFromSearchEngine.
+        // is instead initially set in updateSuggestions().
         if (mSearchEngine != null) {
             setDescriptionOnSuggestion(mUserEnteredTextView, searchTerm);
         }
     }
 
     public void setOnUrlOpenListener(OnUrlOpenListener listener) {
         mUrlOpenListener = listener;
     }
@@ -238,20 +238,17 @@ class SearchEngineRow extends AnimatedHe
                 } while (c.moveToNext());
             }
         } finally {
             c.close();
         }
         hideRecycledSuggestions(suggestionCounter, recycledSuggestionCount);
     }
 
-    private int updateFromSearchEngine(SearchEngine searchEngine, boolean animate, int recycledSuggestionCount) {
-        // Update search engine reference.
-        mSearchEngine = searchEngine;
-
+    private int updateFromSearchEngine(boolean animate, int recycledSuggestionCount) {
         // Set the search engine icon (e.g., Google) for the row.
         mIconView.updateAndScaleImage(mSearchEngine.getIcon(), mSearchEngine.getEngineIdentifier());
 
         // Set the initial content description.
         setDescriptionOnSuggestion(mUserEnteredTextView, mUserEnteredTextView.getText().toString());
 
         int suggestionCounter = 0;
         // Apply Search Engine's suggestions
@@ -266,20 +263,22 @@ class SearchEngineRow extends AnimatedHe
         if (mSelectedView >= mSuggestionView.getChildCount()) {
             mSelectedView = mSuggestionView.getChildCount() - 1;
         }
 
         return suggestionCounter;
     }
 
     public void updateSuggestions(boolean suggestionsEnabled, SearchEngine searchEngine, String searchTerm, boolean animate) {
+        // Update search engine reference. Even if the user has not seen the prompt, we need to set the engine for the mSearchTerm suggestion
+        mSearchEngine = searchEngine;
         // This can be called before the opt-in permission prompt is shown or set. Check first.
         if (suggestionsEnabled) {
             final int recycledSuggestionCount = mSuggestionView.getChildCount();
-            final int suggestionViewCount = updateFromSearchEngine(searchEngine, animate, recycledSuggestionCount);
+            final int suggestionViewCount = updateFromSearchEngine(animate, recycledSuggestionCount);
             if (AppConstants.NIGHTLY_BUILD) {
                 updateFromSavedSearches(searchTerm, animate, suggestionViewCount, recycledSuggestionCount);
             }
         }
     }
 
     @Override
     public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {