From ebaba5b59b4fdb8f2a9cd9ee9a60ff01c1f5f70b Mon Sep 17 00:00:00 2001 From: DatLag Date: Sun, 8 Oct 2023 16:50:36 +0200 Subject: [PATCH] set java.home back to default after init --- kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt | 6 +++++- .../kotlin/dev/datlag/kcef/step/init/CefInitializer.kt | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt b/kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt index 637bb597..d9562c31 100644 --- a/kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt +++ b/kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt @@ -41,7 +41,7 @@ class KCEFBuilder { private val lock = Object() private var building = false private var installed = false - private var downloading = false + private var javaHome: String? = null /** * Sets the installation directory to use. @@ -239,6 +239,7 @@ class KCEFBuilder { this.building = true } install() + javaHome = systemProperty("java.home") this.progress.initializing() synchronized(lock) { // Setting the instance has to occur in the synchronized block to prevent race conditions @@ -248,6 +249,9 @@ class KCEFBuilder { //Notify progress handler this.instance?.onInitialization { state -> if (state == CefApp.CefAppState.INITIALIZED) { + javaHome?.let { home -> + systemProperty("java.home", home) + } this.progress.initialized() } } diff --git a/kcef/src/main/kotlin/dev/datlag/kcef/step/init/CefInitializer.kt b/kcef/src/main/kotlin/dev/datlag/kcef/step/init/CefInitializer.kt index d3721c12..54260c95 100644 --- a/kcef/src/main/kotlin/dev/datlag/kcef/step/init/CefInitializer.kt +++ b/kcef/src/main/kotlin/dev/datlag/kcef/step/init/CefInitializer.kt @@ -2,9 +2,7 @@ package dev.datlag.kcef.step.init import dev.datlag.kcef.KCEFException import dev.datlag.kcef.Platform -import dev.datlag.kcef.common.* import dev.datlag.kcef.common.scopeCatching -import dev.datlag.kcef.common.systemAddPath import dev.datlag.kcef.common.systemLoad import dev.datlag.kcef.common.systemLoadLibrary import dev.datlag.kcef.common.systemProperty @@ -17,7 +15,6 @@ internal data object CefInitializer { fun initialize(installDir: File, cefArgs: Collection, cefSettings: CefSettings): CefApp { val currentOs = Platform.getCurrentPlatform().os - val javaHome = systemProperty("java.home") if (currentOs.isMacOSX) { systemProperty("java.home", (currentOs as Platform.OS.MACOSX).getFrameworkPath(installDir)) @@ -52,11 +49,7 @@ internal data object CefInitializer { val success = if (currentOs.isMacOSX) { val macOs = currentOs as Platform.OS.MACOSX - val started = CefApp.startup(macOs.getFixedArgs(installDir, cefArgs).toTypedArray()) - if (javaHome != null) { - systemProperty("java.home", javaHome) - } - started + CefApp.startup(macOs.getFixedArgs(installDir, cefArgs).toTypedArray()) } else { CefApp.startup(cefArgs.toTypedArray()) }