[tests] fixed: use expire condition instead isDisposed check for EDT tasks with project

GitOrigin-RevId: f69fbfbee573ed15ac0762aab12815c969cfe6ad
This commit is contained in:
Sergei Vorobyov
2022-07-20 18:43:22 +02:00
committed by intellij-monorepo-bot
parent 98141e6ee3
commit 97faa11ac5
2 changed files with 9 additions and 8 deletions

View File

@@ -5,8 +5,10 @@ import com.intellij.openapi.components.ComponentManager;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated Use instead invokeLater with expire condition or use coroutines with component scope.
* @author Vladislav.Soroka
*/
@Deprecated(forRemoval = true)
public abstract class DisposeAwareProjectChange implements Runnable {
private final ComponentManager myComponentManager;

View File

@@ -167,24 +167,23 @@ public final class ProjectDataManagerImpl implements ProjectDataManager {
}
private static void runFinalTasks(@NotNull Project project, boolean synchronous, List<? extends Runnable> tasks) {
Runnable runnable = new DisposeAwareProjectChange(project) {
@Override
public void execute() {
for (Runnable task : ContainerUtil.reverse(tasks)) {
task.run();
}
Runnable runnable = () -> {
for (Runnable task : ContainerUtil.reverse(tasks)) {
task.run();
}
};
if (synchronous) {
try {
runnable.run();
if (!project.isDisposed()) {
runnable.run();
}
}
catch (Exception e) {
LOG.warn(e);
}
}
else {
ApplicationManager.getApplication().invokeLater(runnable);
ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
}
}