Skip to content

Commit

Permalink
set java.home back to default after init
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Oct 8, 2023
1 parent 95f8adf commit ebaba5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 5 additions & 1 deletion kcef/src/main/kotlin/dev/datlag/kcef/KCEFBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,7 +15,6 @@ internal data object CefInitializer {

fun initialize(installDir: File, cefArgs: Collection<String>, 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))
Expand Down Expand Up @@ -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())
}
Expand Down

0 comments on commit ebaba5b

Please sign in to comment.