WI-1153 (Exception when closing one of two opened projects)
authorirengrig <Irina.Chernushina@jetbrains.com>
Wed, 24 Feb 2010 07:57:00 +0000 (10:57 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Wed, 24 Feb 2010 07:57:00 +0000 (10:57 +0300)
!!! Editor not released bug fixed

platform/platform-api/src/com/intellij/openapi/editor/DisposableEditorPanel.java
platform/platform-api/src/com/intellij/util/ui/EditorAdapter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java

index 407f5fa63f91b5389ae55a63664badc0dbcaec7b..cdd745e550f27db1c70c3c58697036181513b56f 100644 (file)
@@ -33,6 +33,8 @@ public class DisposableEditorPanel extends JPanel implements Disposable {
   }
 
   public void dispose() {
-    EditorFactory.getInstance().releaseEditor(myEditor);
+    if (! myEditor.isDisposed()) {
+      EditorFactory.getInstance().releaseEditor(myEditor);
+    }
   }
 }
index 52f6a9d177b9ea3f755bc08468b59faf7d8fdc4e..90df1f16d079f221ebea178eb46b720ad96b8b07 100644 (file)
@@ -81,6 +81,10 @@ public class EditorAdapter {
     LOG.assertTrue(myEditor.isViewer());
   }
 
+  public Editor getEditor() {
+    return myEditor;
+  }
+
   public void appendString(String string, TextAttributes attrs) {
     synchronized (myLines) {
       myLines.add(new Line(string, attrs));
index 8446ab8ed23bb3a3fd0b0cc6b8b8dd6acc39c6fb..f3158a3d8bf1ba28607330b05f96dd2f75f2cbf0 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.components.ProjectComponent;
 import com.intellij.openapi.components.StorageScheme;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.DisposableEditorPanel;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.EditorFactory;
 import com.intellij.openapi.editor.EditorSettings;
@@ -64,7 +63,10 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
+import java.awt.*;
 import java.util.*;
+import java.util.List;
 
 public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx implements ProjectComponent, JDOMExternalizable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl");
@@ -244,6 +246,12 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
     synchronized (myDisposeLock) {
       if (myIsDisposed) return;
 
+      if (myEditorAdapter != null) {
+        final Editor editor = myEditorAdapter.getEditor();
+        if (! editor.isDisposed()) {
+          EditorFactory.getInstance().releaseEditor(editor);
+        }
+      }
       myMappings.disposeMe();
       try {
         myContentManager = null;
@@ -319,7 +327,10 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes
       editorSettings.setFoldingOutlineShown(false);
 
       myEditorAdapter = new EditorAdapter(editor, myProject);
-      content = ContentFactory.SERVICE.getInstance().createContent(new DisposableEditorPanel(editor), displayName, true);
+      final JPanel panel = new JPanel(new BorderLayout());
+      panel.add(editor.getComponent(), BorderLayout.CENTER);
+
+      content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, true);
       contentManager.addContent(content);
 
       for (Pair<String, TextAttributes> pair : myPendingOutput) {