Skip to content

Commit 162fed1

Browse files
committed
Resolve Write access is allowed inside write-action only exception
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Write access is allowed inside write-action only (see Application.runWriteAction()); If you access or modify model on EDT consider wrapping your code in WriteIntentReadAction ; see https://jb.gg/ij-platform-threading for details Current thread: Thread[#46,AWT-EventQueue-0,6,main] 1321404175 (EventQueue.isDispatchThread()=true) SystemEventQueueThread: (same) at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:257) at com.intellij.util.concurrency.ThreadingAssertions.throwThreadAccessException(ThreadingAssertions.java:248) at com.intellij.util.concurrency.ThreadingAssertions.assertWriteAccess(ThreadingAssertions.java:233) at com.intellij.openapi.projectRoots.impl.ProjectJdkImpl.commitChanges(ProjectJdkImpl.java:181) at org.elixir_lang.facet.sdk.Editor.reset(Editor.kt:201) at org.elixir_lang.facet.sdk.Editor.<init>(Editor.kt:65) at org.elixir_lang.facet.sdks.Configurable.updateSdkPanel$lambda$0$0(Configurable.kt:197) at org.elixir_lang.facet.sdks.Configurable.updateSdkPanel$lambda$0$1(Configurable.kt:197)
1 parent 3d53a5d commit 162fed1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/org/elixir_lang/facet/sdks/Configurable.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,15 @@ abstract class Configurable: SearchableConfigurable, com.intellij.openapi.option
194194
}
195195

196196
private fun updateSdkPanel(selectedValue: ProjectJdkImpl?) {
197-
val selectedEditor = selectedValue?.let {
198-
editorByProjectJdkImpl.computeIfAbsent(it, { Editor(projectSdksModel, history!!, it) })
199-
}
197+
ApplicationManager.getApplication().runWriteAction {
198+
val selectedEditor = selectedValue?.let {
199+
editorByProjectJdkImpl.computeIfAbsent(it) { key ->
200+
Editor(projectSdksModel, history!!, key)
201+
}
202+
}
200203

201-
sdkPanel.select(selectedEditor, true)
204+
sdkPanel.select(selectedEditor, true)
205+
}
202206
}
203207
}
204208

0 commit comments

Comments
 (0)