mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-691278 vcs: workaround 'Project already disposed' in VcsRepositoryManager
GitOrigin-RevId: 3855f83a6d543631250da39cb61d148a0b19f4b3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
adeb4661ea
commit
84f3e5d473
@@ -29,10 +29,15 @@ public abstract class RepositoryImpl implements Repository {
|
||||
private boolean myDisposed;
|
||||
|
||||
protected RepositoryImpl(@NotNull Project project,
|
||||
@NotNull VirtualFile dir,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
@NotNull VirtualFile dir) {
|
||||
myProject = project;
|
||||
myRootDir = dir;
|
||||
}
|
||||
|
||||
protected RepositoryImpl(@NotNull Project project,
|
||||
@NotNull VirtualFile dir,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
this(project, dir);
|
||||
Disposer.register(parentDisposable, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package git4idea.repo;
|
||||
import com.intellij.dvcs.repo.RepositoryImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -54,9 +55,8 @@ public final class GitRepositoryImpl extends RepositoryImpl implements GitReposi
|
||||
*/
|
||||
private GitRepositoryImpl(@NotNull VirtualFile rootDir,
|
||||
@NotNull VirtualFile gitDir,
|
||||
@NotNull Project project,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
super(project, rootDir, parentDisposable);
|
||||
@NotNull Project project) {
|
||||
super(project, rootDir);
|
||||
myVcs = GitVcs.getInstance(project);
|
||||
myGitDir = gitDir;
|
||||
myRepositoryFiles = GitRepositoryFiles.createInstance(rootDir, gitDir);
|
||||
@@ -112,9 +112,15 @@ public final class GitRepositoryImpl extends RepositoryImpl implements GitReposi
|
||||
@NotNull Project project,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
ProgressManager.checkCanceled();
|
||||
GitRepositoryImpl repository = new GitRepositoryImpl(root, gitDir, project, parentDisposable);
|
||||
GitRepositoryImpl repository = new GitRepositoryImpl(root, gitDir, project);
|
||||
repository.setupUpdater();
|
||||
GitRepositoryManager.getInstance(project).notifyListenersAsync(repository);
|
||||
|
||||
ReadAction.run(() -> {
|
||||
if (!Disposer.tryRegister(parentDisposable, repository)) {
|
||||
Disposer.dispose(repository);
|
||||
}
|
||||
});
|
||||
return repository;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package org.zmlx.hg4idea.repo;
|
||||
import com.intellij.dvcs.ignore.VcsIgnoredHolderUpdateListener;
|
||||
import com.intellij.dvcs.repo.RepositoryImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
|
||||
@@ -46,9 +47,8 @@ public final class HgRepositoryImpl extends RepositoryImpl implements HgReposito
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private HgRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull HgVcs vcs,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
super(vcs.getProject(), rootDir, parentDisposable);
|
||||
private HgRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull HgVcs vcs) {
|
||||
super(vcs.getProject(), rootDir);
|
||||
myVcs = vcs;
|
||||
myHgDir = rootDir.findChild(HgUtil.DOT_HG);
|
||||
assert myHgDir != null : ".hg directory wasn't found under " + rootDir.getPresentableUrl();
|
||||
@@ -69,8 +69,14 @@ public final class HgRepositoryImpl extends RepositoryImpl implements HgReposito
|
||||
if (vcs == null) {
|
||||
throw new IllegalArgumentException("Vcs not found for project " + project);
|
||||
}
|
||||
HgRepositoryImpl repository = new HgRepositoryImpl(root, vcs, parentDisposable);
|
||||
HgRepositoryImpl repository = new HgRepositoryImpl(root, vcs);
|
||||
repository.setupUpdater();
|
||||
|
||||
ReadAction.run(() -> {
|
||||
if (!Disposer.tryRegister(parentDisposable, repository)) {
|
||||
Disposer.dispose(repository);
|
||||
}
|
||||
});
|
||||
return repository;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user