mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
(RIDER-102710) Settings Transfer: allow to override threading assertions in the old wizard
GitOrigin-RevId: 53c5ab0f4102cf7f2e49c0470edef45519832dc0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
06985bae20
commit
e49621617d
@@ -0,0 +1,34 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.startup.importSettings.transfer.backend
|
||||
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.util.ui.EDT
|
||||
|
||||
/**
|
||||
* This is exclusively for legacy settings transfer wizard to not show any warnings.
|
||||
*/
|
||||
object LegacySettingsTransferWizard {
|
||||
|
||||
private val isLegacyThreadingModelStorage = ThreadLocal<Boolean>()
|
||||
private val isLegacyThreadingModel: Boolean
|
||||
get() = isLegacyThreadingModelStorage.get().let { it != null && it }
|
||||
|
||||
@Suppress("unused") // used in Rider
|
||||
fun <T> withRelaxedThreading(action: () -> T): T {
|
||||
assert(!isLegacyThreadingModel)
|
||||
isLegacyThreadingModelStorage.set(true)
|
||||
try {
|
||||
return action()
|
||||
}
|
||||
finally {
|
||||
isLegacyThreadingModelStorage.remove()
|
||||
}
|
||||
}
|
||||
|
||||
fun warnBackgroundThreadIfNotLegacy() {
|
||||
if (isLegacyThreadingModel) return
|
||||
if (EDT.isCurrentThreadEdt()) {
|
||||
thisLogger().error("Should not be called from EDT.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import com.fasterxml.jackson.databind.node.ArrayNode
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeType
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode
|
||||
import com.intellij.ide.startup.importSettings.models.Settings
|
||||
import com.intellij.ide.startup.importSettings.transfer.backend.LegacySettingsTransferWizard
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.concurrency.ThreadingAssertions
|
||||
import java.io.File
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
@@ -24,7 +24,7 @@ class StateDatabaseParser(private val settings: Settings) {
|
||||
private val recentsKey = "history.recentlyOpenedPathsList"
|
||||
|
||||
fun process(file: File) {
|
||||
ThreadingAssertions.assertBackgroundThread()
|
||||
LegacySettingsTransferWizard.warnBackgroundThreadIfNotLegacy()
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user