Commit 60e04ca6 authored by Vladimir Krivosheev's avatar Vladimir Krivosheev Committed by intellij-monorepo-bot
Browse files

IJPL-333 fix for 233

GitOrigin-RevId: de3688e1f2ed3bd287bd8ac9b5c561dc0dd4ce11
parent 9dfd45cf
Branches unavailable Tags unavailable
No related merge requests found
Showing with 30 additions and 13 deletions
+30 -13
......@@ -102,13 +102,10 @@ private suspend fun startApp(args: List<String>, mainScope: CoroutineScope, busy
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(AppMode.isHeadless())
}
val configImportNeededDeferred = if (AppMode.isHeadless()) {
CompletableDeferred(false)
}
else {
async(Dispatchers.IO) {
isConfigImportNeeded(PathManager.getConfigDir())
}
// some code can rely on this flag, even if it is not used to show config import dialog or something config related,
// that's why we check it even in a headless mode (https://youtrack.jetbrains.com/issue/IJPL-333)
val configImportNeededDeferred = async(Dispatchers.IO) {
isConfigImportNeeded(PathManager.getConfigDir())
}
// this check must be performed before system directories are locked
......
......@@ -42,6 +42,7 @@ import com.intellij.util.lang.ZipFilePool
import com.jetbrains.JBR
import io.opentelemetry.sdk.OpenTelemetrySdkBuilder
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.debug.internal.DebugProbesImpl
import org.jetbrains.annotations.ApiStatus.Internal
import org.jetbrains.annotations.VisibleForTesting
......@@ -207,7 +208,16 @@ fun CoroutineScope.startApplication(args: List<String>,
val euaDocumentDeferred = async { loadEuaDocument(appInfoDeferred) }
val configImportDeferred: Deferred<Job?> = async {
if (isHeadless || !configImportNeededDeferred.await()) {
if (isHeadless) {
if (configImportNeededDeferred.await()) {
// make sure we lock the dir before writing
lockSystemDirsJob.join()
enableNewUi(logDeferred)
}
return@async null
}
if (AppMode.isRemoteDevHost() || !configImportNeededDeferred.await()) {
return@async null
}
......@@ -222,11 +232,7 @@ fun CoroutineScope.startApplication(args: List<String>,
)
if (ConfigImportHelper.isNewUser()) {
if (System.getProperty("ide.experimental.ui") == null) {
runCatching {
EarlyAccessRegistryManager.setAndFlush(mapOf("ide.experimental.ui" to "true"))
}.getOrLogException(log)
}
enableNewUi(logDeferred)
if (isIdeStartupWizardEnabled) {
log.info("Will enter initial app wizard flow.")
......@@ -342,6 +348,20 @@ fun CoroutineScope.startApplication(args: List<String>,
}
}
private suspend fun enableNewUi(logDeferred: Deferred<Logger>) {
if (System.getProperty("ide.experimental.ui") == null) {
try {
EarlyAccessRegistryManager.setAndFlush(mapOf("ide.experimental.ui" to "true"))
}
catch (e: CancellationException) {
throw e
}
catch (e: Throwable) {
logDeferred.await().error(e)
}
}
}
@Volatile
@JvmField
internal var isInitialStart: CompletableDeferred<Boolean>? = null
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment