diff --git a/src/main/kotlin/com/github/pemistahl/lingua/app/multilanguage/MultiLanguageModel.kt b/src/main/kotlin/com/github/pemistahl/lingua/app/multilanguage/MultiLanguageModel.kt index 5e13ed0d..4a931d4f 100644 --- a/src/main/kotlin/com/github/pemistahl/lingua/app/multilanguage/MultiLanguageModel.kt +++ b/src/main/kotlin/com/github/pemistahl/lingua/app/multilanguage/MultiLanguageModel.kt @@ -83,6 +83,8 @@ internal class MultiLanguageModel( if (languageDetector != null) { val currentWorkerCancelled = AtomicBoolean(false) this.currentWorkerCancelled = currentWorkerCancelled + // Store property value in local variable to safely access it from worker thread + val text = text currentWorker = object : SwingWorker, Unit>() { override fun doInBackground(): List { return languageDetector.detectMultiLanguageOf(text)