Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Unified Diff: components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java

Issue 2384613002: [Android] Fix spellcheck JNI crash when a tab is closed. (Closed)
Patch Set: more fixes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/spellcheck/browser/spellcheck_message_filter_platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
diff --git a/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java b/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
index f3c5dd8c82d51ce5b9cfa90303d156f1e05cb154..679b2111f960c79d6b14c0b2ee4bdf498015c93c 100644
--- a/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
+++ b/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
* JNI interface for native SpellCheckerSessionBridge to use Android's spellchecker.
*/
public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
- private final long mNativeSpellCheckerSessionBridge;
+ private long mNativeSpellCheckerSessionBridge;
private final SpellCheckerSession mSpellCheckerSession;
/**
@@ -61,6 +61,16 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
}
/**
+ * Reset the native brigde pointer, called when the native counterpart is destroyed.
+ */
+ @CalledByNative
+ private void disconnect() {
+ mNativeSpellCheckerSessionBridge = 0;
+ mSpellCheckerSession.cancel();
+ mSpellCheckerSession.close();
+ }
+
+ /**
* Queries the input text against the SpellCheckerSession.
* @param text Text to be queried.
*/
@@ -82,6 +92,10 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
*/
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
+ if (mNativeSpellCheckerSessionBridge == 0) {
+ return;
+ }
+
ArrayList<Integer> offsets = new ArrayList<Integer>();
ArrayList<Integer> lengths = new ArrayList<Integer>();
@@ -96,7 +110,6 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
}
}
}
-
nativeProcessSpellCheckResults(mNativeSpellCheckerSessionBridge,
convertListToArray(offsets), convertListToArray(lengths));
}
« no previous file with comments | « no previous file | components/spellcheck/browser/spellcheck_message_filter_platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698