@@ -121,6 +121,7 @@ import org.wordpress.aztec.watchers.event.text.BeforeTextChangedEventData
121121import org.wordpress.aztec.watchers.event.text.OnTextChangedEventData
122122import org.wordpress.aztec.watchers.event.text.TextWatcherEvent
123123import org.xml.sax.Attributes
124+ import java.lang.ref.WeakReference
124125import java.security.MessageDigest
125126import java.security.NoSuchAlgorithmException
126127import java.util.ArrayList
@@ -294,7 +295,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
294295
295296 private var focusOnVisible = true
296297
297- var inputConnection : InputConnection ? = null
298+ var inputConnectionRef : WeakReference < InputConnection > ? = null
298299 var inputConnectionEditorInfo: EditorInfo ? = null
299300
300301 interface OnSelectionChangedListener {
@@ -673,7 +674,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
673674 }
674675
675676 // now init the InputConnection, or replace if EditorInfo contains anything different
676- if (inputConnection == null || ! EditorInfoUtils .areEditorInfosTheSame(outAttrs, inputConnectionEditorInfo!! )) {
677+ if (inputConnectionRef?.get() == null || ! EditorInfoUtils .areEditorInfosTheSame(outAttrs, inputConnectionEditorInfo!! )) {
677678 // we have a new InputConnection to create, save the new EditorInfo data and create it
678679 // we make a copy of the parameters being received, because super.onCreateInputConnection may make changes
679680 // to EditorInfo params being sent to it, and we want to preserve the same data we received in order
@@ -689,11 +690,11 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
689690 }
690691 // if non null, wrap the new InputConnection around our wrapper
691692 // inputConnection = AztecTextInputConnectionWrapper(localInputConnection, this)
692- inputConnection = localInputConnection
693+ inputConnectionRef = WeakReference ( localInputConnection)
693694 }
694695
695- // returnn the existing inputConnection
696- return inputConnection !!
696+ // return the existing inputConnection
697+ return inputConnectionRef?.get() !!
697698 }
698699
699700 override fun onRestoreInstanceState (state : Parcelable ? ) {
0 commit comments