Skip to content

Commit

Permalink
🐛 Fix UI blocking during application exit (#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyanakuang authored Sep 4, 2024
1 parent 868a858 commit 88bd1e4
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import kotlinx.coroutines.withContext
import org.koin.core.KoinApplication
Expand Down Expand Up @@ -413,6 +413,7 @@ class CrossPaste {
private suspend fun exitCrossPasteApplication(
exitMode: ExitMode,
scope: CoroutineScope,
exitApplication: () -> Unit,
) = withContext(scope.coroutineContext) {
val koin = koinApplication.koin
val appExitService = koin.get<AppExitService>()
Expand All @@ -430,6 +431,7 @@ class CrossPaste {
val appWindowManager = koin.get<DesktopAppWindowManager>()
appWindowManager.showMainWindow = false
}
exitApplication()
}

private suspend fun shutdownAllServices() {
Expand Down Expand Up @@ -490,10 +492,9 @@ class CrossPaste {
appWindowManager.showMainWindow = false
}
appWindowManager.showSearchWindow = false
runBlocking {
exitCrossPasteApplication(mode, ioScope)
ioScope.launch {
exitCrossPasteApplication(mode, ioScope) { exitApplication() }
}
exitApplication()
}

val currentPageViewContext = remember { mutableStateOf(PageViewContext(PageViewType.PASTE_PREVIEW)) }
Expand Down

0 comments on commit 88bd1e4

Please sign in to comment.