mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't dispose Disposable cached values, since it complicates code and is unreliable anyway
This commit is contained in:
@@ -17,8 +17,10 @@ public class ProfilingInfo {
|
||||
myOrigin = origin;
|
||||
}
|
||||
|
||||
public void valueDisposed() {
|
||||
myDisposedTimeStamp = currentTime();
|
||||
public synchronized void valueDisposed() {
|
||||
if (myDisposedTimeStamp != 0) {
|
||||
myDisposedTimeStamp = currentTime();
|
||||
}
|
||||
}
|
||||
|
||||
public void valueUsed() {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.RecursionGuard;
|
||||
import com.intellij.openapi.util.RecursionManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.util.CachedValueProfiler;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.ProfilingInfo;
|
||||
@@ -99,20 +101,17 @@ public abstract class CachedValueBase<T> {
|
||||
}
|
||||
|
||||
public boolean hasUpToDateValue() {
|
||||
return getUpToDateOrNull(false) != null;
|
||||
return getUpToDateOrNull() != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
final Data<T> getUpToDateOrNull(boolean dispose) {
|
||||
final Data<T> getUpToDateOrNull() {
|
||||
Data<T> data = getRawData();
|
||||
|
||||
if (data != null) {
|
||||
if (isUpToDate(data)) {
|
||||
return data;
|
||||
}
|
||||
if (dispose && data.myValue instanceof Disposable && compareAndClearData(data)) {
|
||||
Disposer.dispose((Disposable)data.myValue);
|
||||
}
|
||||
if (data instanceof ProfilingData) {
|
||||
((ProfilingData<T>)data).myProfilingInfo.valueDisposed();
|
||||
}
|
||||
@@ -196,7 +195,7 @@ public abstract class CachedValueBase<T> {
|
||||
|
||||
public abstract boolean isFromMyProject(Project project);
|
||||
|
||||
protected static class Data<T> implements Disposable {
|
||||
protected static class Data<T> {
|
||||
private final T myValue;
|
||||
private final Object[] myDependencies;
|
||||
private final long[] myTimeStamps;
|
||||
@@ -207,13 +206,6 @@ public abstract class CachedValueBase<T> {
|
||||
myTimeStamps = timeStamps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myValue instanceof Disposable) {
|
||||
Disposer.dispose((Disposable)myValue);
|
||||
}
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return myValue;
|
||||
}
|
||||
@@ -239,7 +231,7 @@ public abstract class CachedValueBase<T> {
|
||||
|
||||
@Nullable
|
||||
protected <P> T getValueWithLock(P param) {
|
||||
Data<T> data = getUpToDateOrNull(true);
|
||||
Data<T> data = getUpToDateOrNull();
|
||||
if (data != null) {
|
||||
return data.getValue();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CachedValuesManagerImpl extends CachedValuesManager {
|
||||
CachedValue<T> value = dataHolder.getUserData(key);
|
||||
if (value instanceof CachedValueBase && ((CachedValueBase)value).isFromMyProject(myProject)) {
|
||||
//noinspection unchecked
|
||||
CachedValueBase.Data<T> data = ((CachedValueBase<T>)value).getUpToDateOrNull(false);
|
||||
CachedValueBase.Data<T> data = ((CachedValueBase<T>)value).getUpToDateOrNull();
|
||||
if (data != null) {
|
||||
return data.getValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user