a more concise way to cancel project-bound progresses automatically on project disposal (IDEA-CR-15966)

This commit is contained in:
peter
2016-11-24 16:13:35 +01:00
parent d9a8f7cc36
commit 4f80e698de
@@ -64,7 +64,6 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro
private String myProcessId = "<unknown>";
@Nullable private volatile Runnable myBackgroundHandler;
private int myDelayInMillis = DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS;
@Nullable private Disposable myCancelOnProjectDisposal;
public interface Listener {
void progressWindowCreated(ProgressWindow pw);
@@ -122,12 +121,7 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro
ApplicationManager.getApplication().getMessageBus().syncPublisher(TOPIC).progressWindowCreated(this);
if (myProject != null) {
myCancelOnProjectDisposal = () -> {
if (isRunning()) {
cancel();
}
};
Disposer.register(myProject, myCancelOnProjectDisposal);
Disposer.register(myProject, this);
}
}
@@ -398,8 +392,8 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro
@Override
public void dispose() {
stopSystemActivity();
if (myCancelOnProjectDisposal != null) {
Disposer.dispose(myCancelOnProjectDisposal);
if (isRunning()) {
cancel();
}
}