try to provide a cause for PCE happening in disposable indicators

e.g. daemon's
This commit is contained in:
peter
2017-06-30 09:29:43 +02:00
parent 288e99245d
commit 11b8ec6ec8
2 changed files with 16 additions and 4 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.progress.util;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.TransactionGuard;
@@ -25,13 +26,16 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.impl.CoreProgressManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.ui.mac.foundation.MacUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.DoubleArrayList;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@@ -127,15 +131,23 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
@Override
public void checkCanceled() {
if (isCanceled() && isCancelable()) {
throw new ProcessCanceledException();
throw new ProcessCanceledException(getDisposeTrace());
}
if (CoreProgressManager.runCheckCanceledHooks(this)) {
if (isCanceled() && isCancelable()) {
throw new ProcessCanceledException();
throw new ProcessCanceledException(getDisposeTrace());
}
}
}
@Nullable
private Throwable getDisposeTrace() {
if (this instanceof Disposable) {
return ObjectUtils.tryCast(Disposer.getTree().getDisposalInfo((Disposable)this), Throwable.class);
}
return null;
}
@Override
public void setText(final String text) {
myText = text;
@@ -16,12 +16,12 @@
package com.intellij.openapi.progress;
import com.intellij.openapi.diagnostic.ControlFlowException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ProcessCanceledException extends RuntimeException implements ControlFlowException {
public ProcessCanceledException() { }
public ProcessCanceledException(@NotNull Throwable cause) {
public ProcessCanceledException(@Nullable Throwable cause) {
super(cause);
if (cause instanceof ProcessCanceledException) {
throw new IllegalArgumentException("Must not self-wrap ProcessCanceledException: " + cause);