mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
Force save PSC to disk if forceSaveAll is used and switched off StreamProvider
GitOrigin-RevId: 5a58389702df9305491c763f05440d494c5acd9b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e8967c1259
commit
4c3b7d5a09
@@ -243,7 +243,7 @@ abstract class ComponentStoreImpl : IComponentStore {
|
||||
SAVE_MOD_LOG.debug(
|
||||
"${if (isUseModificationCount) "Skip " else ""}$name: modificationCount $currentModificationCount equals to last saved")
|
||||
}
|
||||
if (isUseModificationCount) {
|
||||
if (isUseModificationCount && !isForce) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ class CompoundStreamProvider : StreamProvider {
|
||||
private val providers = ContainerUtil.createConcurrentList<StreamProvider>()
|
||||
private val providerListModificationCount = AtomicInteger()
|
||||
|
||||
override val saveStorageDataOnReload: Boolean // true by default
|
||||
get() = !providers.any { !it.saveStorageDataOnReload }
|
||||
|
||||
override val enabled: Boolean
|
||||
get() = providers.any { it.enabled }
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ abstract class XmlElementStorage protected constructor(val fileSpec: String,
|
||||
private val pathMacroSubstitutor: PathMacroSubstitutor? = null,
|
||||
val roamingType: RoamingType,
|
||||
private val provider: StreamProvider? = null) : StorageBaseEx<StateMap>() {
|
||||
override val saveStorageDataOnReload: Boolean
|
||||
get() {
|
||||
return provider == null || provider.saveStorageDataOnReload
|
||||
}
|
||||
|
||||
protected abstract fun loadLocalData(): Element?
|
||||
|
||||
final override fun getSerializedState(storageData: StateMap, component: Any?, componentName: String, archive: Boolean): Element? {
|
||||
|
||||
@@ -17,6 +17,9 @@ abstract class StateStorageBase<T : Any> : StateStorage {
|
||||
|
||||
protected val storageDataRef: AtomicReference<T> = AtomicReference()
|
||||
|
||||
protected open val saveStorageDataOnReload: Boolean
|
||||
get() = true
|
||||
|
||||
override fun <T : Any> getState(component: Any?, componentName: String, stateClass: Class<T>, mergeInto: T?, reload: Boolean): T? {
|
||||
return getState(component, componentName, stateClass, reload, mergeInto)
|
||||
}
|
||||
@@ -41,17 +44,26 @@ abstract class StateStorageBase<T : Any> : StateStorage {
|
||||
}
|
||||
|
||||
protected fun getStorageData(reload: Boolean = false): T {
|
||||
val storageData = storageDataRef.get()
|
||||
if (storageData != null && !reload) {
|
||||
return storageData
|
||||
val currentStorageData = storageDataRef.get()
|
||||
if (currentStorageData != null && !reload) {
|
||||
return currentStorageData
|
||||
}
|
||||
|
||||
val newStorageData = loadData()
|
||||
if (storageDataRef.compareAndSet(storageData, newStorageData)) {
|
||||
if (reload && !saveStorageDataOnReload) {
|
||||
// it means, that you MUST invoke save all settings after reload
|
||||
if (storageDataRef.compareAndSet(currentStorageData, null)) {
|
||||
return newStorageData
|
||||
}
|
||||
else {
|
||||
return getStorageData(reload = true)
|
||||
}
|
||||
}
|
||||
else if (storageDataRef.compareAndSet(currentStorageData, newStorageData)) {
|
||||
return newStorageData
|
||||
}
|
||||
else {
|
||||
return getStorageData(false)
|
||||
return getStorageData(reload = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ interface StreamProvider {
|
||||
*/
|
||||
val isExclusive: Boolean
|
||||
|
||||
val saveStorageDataOnReload: Boolean
|
||||
get() = true
|
||||
|
||||
/**
|
||||
* Called only on `write`
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user