diff --git a/next/kmp/app/desktopApp/src/desktopMain/kotlin/main.kt b/next/kmp/app/desktopApp/src/desktopMain/kotlin/main.kt index 1682dcda6f..34b6537923 100644 --- a/next/kmp/app/desktopApp/src/desktopMain/kotlin/main.kt +++ b/next/kmp/app/desktopApp/src/desktopMain/kotlin/main.kt @@ -1,6 +1,7 @@ import kotlinx.coroutines.async import org.dweb_browser.helper.WARNING import org.dweb_browser.helper.globalDefaultScope +import org.dweb_browser.helper.ioAsyncExceptionHandler import org.dweb_browser.helper.platform.PureViewController import kotlin.system.exitProcess @@ -25,24 +26,24 @@ suspend fun main(vararg args: String) { return } -try { - val dnsNMMDeferred = globalDefaultScope.async { - // 等待“应用”准备完毕 - PureViewController.awaitPrepared() - // 启动内核 - startDwebBrowser( - System.getenv("debug") ?: System.getProperty("debug"), - listOf() //ExtMM(TrayNMM(), true) - ) - } - // 启动“应用” - PureViewController.startApplication() + try { + val dnsNMMDeferred = globalDefaultScope.async(ioAsyncExceptionHandler) { + // 等待“应用”准备完毕 + PureViewController.awaitPrepared() + // 启动内核 + startDwebBrowser( + System.getenv("debug") ?: System.getProperty("debug"), + listOf() //ExtMM(TrayNMM(), true) + ) + } + // 启动“应用” + PureViewController.startApplication() - dnsNMMDeferred.await().runtimeOrNull?.shutdown() -} catch (e:Exception) { - WARNING("global catch error : $e") - e.printStackTrace() -} finally { - exitProcess(0) -} + dnsNMMDeferred.await().runtimeOrNull?.shutdown() + } catch (e: Exception) { + WARNING("global catch error : $e") + e.printStackTrace() + } finally { + exitProcess(0) + } } \ No newline at end of file diff --git a/next/kmp/dwebview/src/commonMain/kotlin/org/dweb_browser/dwebview/DWebView.kt b/next/kmp/dwebview/src/commonMain/kotlin/org/dweb_browser/dwebview/DWebView.kt index e131537a7e..9552c308a7 100644 --- a/next/kmp/dwebview/src/commonMain/kotlin/org/dweb_browser/dwebview/DWebView.kt +++ b/next/kmp/dwebview/src/commonMain/kotlin/org/dweb_browser/dwebview/DWebView.kt @@ -24,6 +24,7 @@ import org.dweb_browser.core.ipc.helper.IWebMessagePort import org.dweb_browser.core.module.MicroModule import org.dweb_browser.helper.Bounds import org.dweb_browser.helper.Debugger +import org.dweb_browser.helper.Once import org.dweb_browser.helper.RememberLazy import org.dweb_browser.helper.Signal import org.dweb_browser.helper.SimpleSignal @@ -248,9 +249,9 @@ class DestroyStateSignal(val scope: CoroutineScope) { private set private var _destroySignal = SimpleSignal(); val onDestroy = _destroySignal.toListener() - fun doDestroy(): Boolean { + fun doDestroy() = Once { if (isDestroyed) { - return false + return@Once false } debugDWebView("DESTROY") isDestroyed = true @@ -259,6 +260,6 @@ class DestroyStateSignal(val scope: CoroutineScope) { delay(2000) coroutineContext.cancel(CancellationException("destroy")) } - return true - } + return@Once true + }.invoke() } \ No newline at end of file diff --git a/next/kmp/helper/ui/src/commonMain/kotlin.link b/next/kmp/helper/ui/src/commonMain/kotlin.link deleted file mode 120000 index fec5f55f22..0000000000 --- a/next/kmp/helper/ui/src/commonMain/kotlin.link +++ /dev/null @@ -1 +0,0 @@ -../../../src/commonMain/kotlin \ No newline at end of file