From ea9ead4f055f66977cedc8514d472507e228afdc Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Thu, 18 Apr 2024 14:15:32 +0800 Subject: [PATCH] :bug: Fixed the issue where the chrome-driver chrome-headless-shell process was not closed when the application exited (#757) --- .../src/commonMain/kotlin/com/clipevery/clip/ChromeService.kt | 2 ++ .../kotlin/com/clipevery/clip/DesktopChromeService.kt | 4 ++++ composeApp/src/desktopMain/kotlin/com/clipevery/main.kt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/com/clipevery/clip/ChromeService.kt b/composeApp/src/commonMain/kotlin/com/clipevery/clip/ChromeService.kt index 9753b5b4c..10f0978af 100644 --- a/composeApp/src/commonMain/kotlin/com/clipevery/clip/ChromeService.kt +++ b/composeApp/src/commonMain/kotlin/com/clipevery/clip/ChromeService.kt @@ -3,4 +3,6 @@ package com.clipevery.clip interface ChromeService { fun html2Image(html: String): ByteArray? + + fun quit() } diff --git a/composeApp/src/desktopMain/kotlin/com/clipevery/clip/DesktopChromeService.kt b/composeApp/src/desktopMain/kotlin/com/clipevery/clip/DesktopChromeService.kt index 494f138ce..8a4cb74f1 100644 --- a/composeApp/src/desktopMain/kotlin/com/clipevery/clip/DesktopChromeService.kt +++ b/composeApp/src/desktopMain/kotlin/com/clipevery/clip/DesktopChromeService.kt @@ -119,6 +119,10 @@ object DesktopChromeService : ChromeService { } } + override fun quit() { + chromeDriver?.quit() + } + @Suppress("UNCHECKED_CAST") private fun doHtml2Image(html: String): ByteArray? { chromeDriver?.let { driver -> diff --git a/composeApp/src/desktopMain/kotlin/com/clipevery/main.kt b/composeApp/src/desktopMain/kotlin/com/clipevery/main.kt index 553a69c97..66a99bcb7 100644 --- a/composeApp/src/desktopMain/kotlin/com/clipevery/main.kt +++ b/composeApp/src/desktopMain/kotlin/com/clipevery/main.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.window.rememberWindowState import com.clipevery.app.AppFileType import com.clipevery.app.AppUI import com.clipevery.clean.CleanClipScheduler +import com.clipevery.clip.ChromeService import com.clipevery.clip.ClipSearchService import com.clipevery.clip.ClipboardService import com.clipevery.listen.GlobalListener @@ -49,6 +50,7 @@ fun exitClipEveryApplication(exitApplication: () -> Unit) { koinApplication.koin.get().unregisterService() koinApplication.koin.get().stop() koinApplication.koin.get().stop() + koinApplication.koin.get().quit() exitApplication() }