memory leak in tests
authorDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Fri, 23 Sep 2016 14:22:17 +0000 (17:22 +0300)
committerDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Fri, 23 Sep 2016 14:23:25 +0000 (17:23 +0300)
platform/lang-impl/src/com/intellij/application/options/colors/ScopeColorsPageFactory.java

index ffe5afdadfe4469aa4de51fb98bde82e6b7f9aa8..cba8bb463ef3b45a97b7a0a9e0b4bd98a856e3d4 100644 (file)
@@ -20,9 +20,11 @@ import com.intellij.ide.DataManager;
 import com.intellij.ide.util.scopeChooser.EditScopesDialog;
 import com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.options.ex.Settings;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
+import com.intellij.util.ui.JBUI;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
@@ -56,9 +58,7 @@ class ScopeColorsPageFactory implements ColorAndFontPanelFactory {
     //panel.setBorder(new LineBorder(Color.red));
     if (projects.length == 0) return panel;
     GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
-                                                   new Insets(0, 0, 0, 0), 0, 0);
-    final Project contextProject = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
-    final Project project = contextProject != null ? contextProject : projects[0];
+                                                   JBUI.emptyInsets(), 0, 0);
 
     JButton button = new JButton("Manage Scopes...");
     button.setPreferredSize(new Dimension(230, button.getPreferredSize().height));
@@ -74,7 +74,9 @@ class ScopeColorsPageFactory implements ColorAndFontPanelFactory {
     button.addActionListener(new ActionListener() {
       @Override
       public void actionPerformed(@NotNull ActionEvent e) {
-        Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext());
+        DataContext context = DataManager.getInstance().getDataContext(panel);
+        Settings settings = Settings.KEY.getData(context);
+        Project project = CommonDataKeys.PROJECT.getData(context);
         if (settings != null) {
           try {
             if (settings.select(settings.find(ScopeChooserConfigurable.PROJECT_SCOPES)).isRejected()) {