mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
[java-analysis] InferNullityAnnotationsAction: avoid storing myUi after the dialog is finished
Otherwise, resource leaks are possible through it. Fixes IDEA-346071 com.intellij.codeInspection.inferNullity.InferNullityAnnotationsAction holds disposed ProjectImpl GitOrigin-RevId: f84ae2575a8ef6d0f88fc3bde769d913ae664ac5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a1be79f27
commit
e40396352c
@@ -50,7 +50,6 @@ import com.intellij.refactoring.RefactoringBundle;
|
|||||||
import com.intellij.usageView.UsageInfo;
|
import com.intellij.usageView.UsageInfo;
|
||||||
import com.intellij.usageView.UsageViewUtil;
|
import com.intellij.usageView.UsageViewUtil;
|
||||||
import com.intellij.usages.*;
|
import com.intellij.usages.*;
|
||||||
import com.intellij.util.LazyInitializer;
|
|
||||||
import com.intellij.util.ObjectUtils;
|
import com.intellij.util.ObjectUtils;
|
||||||
import com.intellij.util.Processor;
|
import com.intellij.util.Processor;
|
||||||
import com.intellij.util.SequentialModalProgressTask;
|
import com.intellij.util.SequentialModalProgressTask;
|
||||||
@@ -67,7 +66,7 @@ import java.util.*;
|
|||||||
public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
||||||
private static final String SUGGEST_ANNOTATION_DEPENDENCY = "java.suggest.annotation.dependency";
|
private static final String SUGGEST_ANNOTATION_DEPENDENCY = "java.suggest.annotation.dependency";
|
||||||
private static final @NonNls String ANNOTATE_LOCAL_VARIABLES = "checkbox.annotate.local.variables";
|
private static final @NonNls String ANNOTATE_LOCAL_VARIABLES = "checkbox.annotate.local.variables";
|
||||||
private final LazyInitializer.@NotNull LazyValue<InferNullityAdditionalUi> myUi = LazyInitializer.create(InferNullityAdditionalUi::new);
|
private InferNullityAdditionalUi myUi;
|
||||||
private static final NotificationGroup NOTIFICATION_GROUP = NotificationGroupManager
|
private static final NotificationGroup NOTIFICATION_GROUP = NotificationGroupManager
|
||||||
.getInstance()
|
.getInstance()
|
||||||
.getNotificationGroup("Infer Nullity");
|
.getNotificationGroup("Infer Nullity");
|
||||||
@@ -78,6 +77,21 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void analyze(final @NotNull Project project, final @NotNull AnalysisScope scope) {
|
protected void analyze(final @NotNull Project project, final @NotNull AnalysisScope scope) {
|
||||||
|
try {
|
||||||
|
doAnalysis(project, scope);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void canceled() {
|
||||||
|
super.canceled();
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doAnalysis(@NotNull Project project, @NotNull AnalysisScope scope) {
|
||||||
PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, isAnnotateLocalVariables());
|
PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, isAnnotateLocalVariables());
|
||||||
|
|
||||||
final ProgressManager progressManager = ProgressManager.getInstance();
|
final ProgressManager progressManager = ProgressManager.getInstance();
|
||||||
@@ -236,7 +250,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAnnotateLocalVariables() {
|
protected boolean isAnnotateLocalVariables() {
|
||||||
return myUi.get().getCheckBox().isSelected();
|
return myUi.getCheckBox().isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull Runnable applyRunnable(final @NotNull Project project, final @NotNull Computable<UsageInfo[]> computable) {
|
private static @NotNull Runnable applyRunnable(final @NotNull Project project, final @NotNull Computable<UsageInfo[]> computable) {
|
||||||
@@ -343,11 +357,15 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dispose() {
|
||||||
|
myUi = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JComponent getAdditionalActionSettings(@NotNull Project project, BaseAnalysisActionDialog dialog) {
|
protected @Nullable JComponent getAdditionalActionSettings(@NotNull Project project, BaseAnalysisActionDialog dialog) {
|
||||||
InferNullityAdditionalUi ui = myUi.get();
|
myUi = new InferNullityAdditionalUi();
|
||||||
ui.getCheckBox().setSelected(PropertiesComponent.getInstance().getBoolean(ANNOTATE_LOCAL_VARIABLES));
|
myUi.getCheckBox().setSelected(PropertiesComponent.getInstance().getBoolean(ANNOTATE_LOCAL_VARIABLES));
|
||||||
return ui.getPanel();
|
return myUi.getPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user