mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-66238 Remove the indicator disposable when SDK update is finished to prevent leaking it
GitOrigin-RevId: 35b6431a675d0f666516291dab81bdaa107650d6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ee8e8a5e9c
commit
778212aec0
@@ -132,7 +132,8 @@ public final class PythonSdkUpdater {
|
||||
return;
|
||||
}
|
||||
// This explicit cancellation should become unnecessary on migrating PythonSdkUpdater to coroutines and withBackgroundProgress
|
||||
cancelIndicatorOnProjectDisposal(indicator);
|
||||
Disposable indicatorDisposable = getIndicatorDisposable(indicator);
|
||||
Disposer.register(PythonPluginDisposable.getInstance(myProject), indicatorDisposable);
|
||||
if (Trigger.LOG.isDebugEnabled()) {
|
||||
Trigger.LOG.debug(
|
||||
"Starting SDK refresh for '" + mySdk.getName() + "' triggered by " + Trigger.getCauseByTrace(myRequestData.myTraceback));
|
||||
@@ -161,20 +162,24 @@ public final class PythonSdkUpdater {
|
||||
LOG.warn("Update for SDK " + mySdk.getName() + " failed", e);
|
||||
}
|
||||
finally {
|
||||
// restart code analysis
|
||||
ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(myProject).restart(), myProject.getDisposed());
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
Disposer.dispose(indicatorDisposable);
|
||||
// restart code analysis
|
||||
DaemonCodeAnalyzer.getInstance(myProject).restart();
|
||||
}, myProject.getDisposed());
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelIndicatorOnProjectDisposal(@NotNull ProgressIndicator indicator) {
|
||||
Disposable indicatorDisposable = indicator instanceof Disposable disposable ? disposable : new Disposable() {
|
||||
private @NotNull Disposable getIndicatorDisposable(@NotNull ProgressIndicator indicator) {
|
||||
return indicator instanceof Disposable disposable ? disposable : new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
LOG.info("Cancelling update for " + mySdk + " due to project " + myProject + " disposal");
|
||||
indicator.cancel();
|
||||
LOG.info("Cancelling update for " + mySdk);
|
||||
if (indicator.isRunning()) {
|
||||
indicator.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
Disposer.register(PythonPluginDisposable.getInstance(myProject), indicatorDisposable);
|
||||
}
|
||||
|
||||
private void refreshPackages(@NotNull Sdk sdk, @NotNull ProgressIndicator indicator) {
|
||||
|
||||
Reference in New Issue
Block a user