Skip to content

Commit

Permalink
Fix thread-safety issue with multi-language detection GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Oct 30, 2023
1 parent 407ae88 commit 42a5231
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<LanguageDetector.LanguageSection>, Unit>() {
override fun doInBackground(): List<LanguageDetector.LanguageSection> {
return languageDetector.detectMultiLanguageOf(text)
Expand Down

0 comments on commit 42a5231

Please sign in to comment.