Load workspaces in the main thread

Fixes #147.
This commit is contained in:
Fingercomp 2025-01-23 02:08:01 +03:00
parent 33b08dcef8
commit 82b35d9dbc
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37

View File

@ -404,13 +404,16 @@ object OcelotDesktop
val selectedFile = val selectedFile =
Option.when(chooser.showDialog(null, null) == JFileChooser.APPROVE_OPTION)(chooser.getSelectedFile) Option.when(chooser.showDialog(null, null) == JFileChooser.APPROVE_OPTION)(chooser.getSelectedFile)
// users of [showFileChooserDialog] expect that the continuation is run on the main thread.
// let's meet this expectation.
UiHandler.UiThreadTasks.add(() => {
val result = f(selectedFile) val result = f(selectedFile)
result match { result match {
case f@Failure(_) => showFailureMessage(f) case f@Failure(_) => showFailureMessage(f)
case Success(_) => case Success(_) =>
} }
})
}).start() }).start()
} }