diff: fix memory leak in dirdiff

installFileCompletion() with null Disposable will register itself on DialogWrapper from focused component (or on application-wide Disposable "ui").
We can show dirdiff in FrameWrapper/ToolWindow now, so we should provide right Disposable.
This commit is contained in:
Aleksey Pivovarov
2015-03-26 16:17:51 +03:00
parent b05495806f
commit f219b19ddf
3 changed files with 15 additions and 4 deletions
@@ -55,7 +55,7 @@
<constraints border-constraint="West"/>
<properties/>
</component>
<component id="ee75f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="mySourceDirField">
<component id="ee75f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="mySourceDirField" custom-create="true">
<constraints border-constraint="Center"/>
<properties/>
</component>
@@ -72,7 +72,7 @@
<constraints border-constraint="West"/>
<properties/>
</component>
<component id="cc2ae" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myTargetDirField">
<component id="cc2ae" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myTargetDirField" custom-create="true">
<constraints border-constraint="Center"/>
<properties/>
</component>
@@ -511,6 +511,9 @@ public class DirDiffPanel implements Disposable, DataProvider {
}
private void createUIComponents() {
mySourceDirField = new TextFieldWithBrowseButton(null, this);
myTargetDirField = new TextFieldWithBrowseButton(null, this);
final AtomicBoolean callUpdate = new AtomicBoolean(true);
myRootPanel = new JPanel(new BorderLayout()) {
@Override
@@ -41,15 +41,23 @@ public class TextFieldWithBrowseButton extends ComponentWithBrowseButton<JTextFi
}
public TextFieldWithBrowseButton(JTextField field, @Nullable ActionListener browseActionListener) {
this(field, browseActionListener, null);
}
public TextFieldWithBrowseButton(JTextField field, @Nullable ActionListener browseActionListener, @Nullable Disposable parent) {
super(field, browseActionListener);
if (!(field instanceof JBTextField)) {
UIUtil.addUndoRedoActions(field);
}
installPathCompletion(FileChooserDescriptorFactory.createSingleLocalFileDescriptor());
installPathCompletion(FileChooserDescriptorFactory.createSingleLocalFileDescriptor(), parent);
}
public TextFieldWithBrowseButton(ActionListener browseActionListener) {
this(new JBTextField(10/* to prevent field to be infinitely resized in grid-box layouts */), browseActionListener);
this(browseActionListener, null);
}
public TextFieldWithBrowseButton(ActionListener browseActionListener, Disposable parent) {
this(new JBTextField(10/* to prevent field to be infinitely resized in grid-box layouts */), browseActionListener, parent);
}
public void addBrowseFolderListener(@Nullable String title, @Nullable String description, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor) {