diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java index 4c03ca897322..8b730949a083 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java @@ -49,8 +49,13 @@ public final class ObjectTree { return myObject2NodeMap.get(object); } - ObjectNode putNode(@NotNull T object, @Nullable("null means remove") ObjectNode node) { - return node == null ? myObject2NodeMap.remove(object) : myObject2NodeMap.put(object, node); + void putNode(@NotNull T object, @Nullable("null means remove") ObjectNode node) { + if (node == null) { + myObject2NodeMap.remove(object); + } + else { + myObject2NodeMap.put(object, node); + } } @NotNull @@ -66,7 +71,9 @@ public final class ObjectTree { "(see the cause for stacktrace) so the child: "+child+" will never be disposed", wasDisposed instanceof Throwable ? (Throwable)wasDisposed : null); } - + if (isDisposing(parent)) { + throw new IncorrectOperationException("Sorry but parent: " + parent + " is being disposed so the child: "+child+" will never be disposed"); + } synchronized (treeLock) { myDisposedObjects.remove(child); // if we dispose thing and then register it back it means it's not disposed anymore ObjectNode parentNode = getNode(parent); @@ -120,7 +127,7 @@ public final class ObjectTree { return myModification.incrementAndGet(); } - public final boolean executeAll(@NotNull T object, @NotNull ObjectTreeAction action, boolean processUnregistered) { + public final void executeAll(@NotNull T object, @NotNull ObjectTreeAction action, boolean processUnregistered) { ObjectNode node; synchronized (treeLock) { node = getNode(object); @@ -129,12 +136,11 @@ public final class ObjectTree { if (processUnregistered) { rememberDisposedTrace(object); executeUnregistered(object, action); - return true; } - return false; } - node.execute(action); - return true; + else { + node.execute(action); + } } public boolean isDisposing(@NotNull T disposable) {