mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assertion for circular progress indicators to avoid EA-76328 - SOE: CoreProgressManager.registerIndicatorAndRun
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,13 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class ProgressManager extends ProgressIndicatorProvider {
|
||||
private static class ProgressManagerHolder {
|
||||
@@ -191,4 +193,14 @@ public abstract class ProgressManager extends ProgressIndicatorProvider {
|
||||
public abstract void executeProcessUnderProgress(@NotNull Runnable process,
|
||||
@Nullable("null means reuse current progress") ProgressIndicator progress)
|
||||
throws ProcessCanceledException;
|
||||
|
||||
public static void assertNotCircular(@NotNull ProgressIndicator original) {
|
||||
Set<ProgressIndicator> wrappedParents = null;
|
||||
for (ProgressIndicator parent = original; parent instanceof WrappedProgressIndicator; parent = ((WrappedProgressIndicator)parent).getOriginalProgressIndicator()) {
|
||||
if (wrappedParents == null) wrappedParents = new THashSet<ProgressIndicator>();
|
||||
if (!wrappedParents.add(parent)) {
|
||||
throw new IllegalArgumentException(parent + " wraps itself");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ package com.intellij.openapi.progress.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.StandardProgressIndicator;
|
||||
import com.intellij.openapi.progress.WrappedProgressIndicator;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -48,6 +49,7 @@ public class ProgressWrapper extends AbstractProgressIndicatorBase implements Wr
|
||||
if (nested > 50) {
|
||||
LOG.error("Too many wrapped indicators");
|
||||
}
|
||||
ProgressManager.assertNotCircular(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ public class DelegatingProgressIndicator implements WrappedProgressIndicator, St
|
||||
|
||||
public DelegatingProgressIndicator(@NotNull ProgressIndicator indicator) {
|
||||
myIndicator = indicator;
|
||||
ProgressManager.assertNotCircular(indicator);
|
||||
}
|
||||
|
||||
public DelegatingProgressIndicator() {
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.progress.util;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.StandardProgressIndicator;
|
||||
import com.intellij.openapi.progress.WrappedProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -67,6 +68,7 @@ public class SmoothProgressAdapter extends AbstractProgressIndicatorExBase imple
|
||||
myOriginal.setModalityProgress(this);
|
||||
setModalityProgress(this);
|
||||
}
|
||||
ProgressManager.assertNotCircular(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user