Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Kubitz2021-06-28 13:04:27 +0000
committerAndrey Loskutov2022-02-03 05:57:07 +0000
commita965822c2c3d24fc50ef5191e9208b6b49ad1a8b (patch)
treee9280d11d377f3570bdc0088954856a9eb628c91 /org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
parent10d62d0982abb87a5d90da3c8373baf3a8576fc8 (diff)
downloadeclipse.platform.text-a965822c2c3d24fc50ef5191e9208b6b49ad1a8b.tar.gz
eclipse.platform.text-a965822c2c3d24fc50ef5191e9208b6b49ad1a8b.tar.xz
eclipse.platform.text-a965822c2c3d24fc50ef5191e9208b6b49ad1a8b.zip
fTextEditor is null after disconnectEditor() for example due to AbstractTextEditor.dispose. A disconnected Editor should not write anything anymore. Change-Id: I2d24a33b255c6c04c5dd8b27b900b1418ce30aec Signed-off-by: Joerg Kubitz <jkubitz-eclipse@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/182543 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java53
1 files changed, 36 insertions, 17 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 6ae6eb053d3..67ef5234995 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -7099,6 +7099,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
/** The cached document. */
private IDocument fDocument;
+ /** for debug only. see Bug 569286 **/
+ private Exception disconnectStack;
+ private boolean disconnectStackShown;
+
/**
* Creates a new savable for this text editor.
*
@@ -7116,7 +7120,12 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
public void disconnectEditor() {
getAdapter(IDocument.class); // make sure the document is cached
- fTextEditor= null;
+ if (disconnectStack == null && !disconnectStackShown) {
+ disconnectStack = new IllegalStateException(
+ "Disconnected before saving. Please post stacktrace to https://bugs.eclipse.org/bugs/show_bug.cgi?id=569286 " //$NON-NLS-1$
+ + fTextEditor.getClass().getName() + " " + getName()); //$NON-NLS-1$
+ }
+ fTextEditor = null;
}
@Override
@@ -7136,31 +7145,41 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void doSave(IProgressMonitor monitor) throws CoreException {
- try {
- fTextEditor.doSave(monitor);
- } catch (NullPointerException e) {
+ ITextEditor textEditor = fTextEditor;
+ if (textEditor == null) { // disconnected Editor - for example due to disposed
// This should not happen. Code added to handle the below bug.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=550336
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log = Platform.getLog(bundle);
- Status status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, null, e);
- log.log(status);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569286
+ if (disconnectStack != null && !disconnectStackShown) {
+ Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
+ ILog log = Platform.getLog(bundle);
+ disconnectStack.addSuppressed(new IllegalStateException("doSave after disconnect")); //$NON-NLS-1$
+ Status status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, null, disconnectStack);
+ log.log(status);
+ disconnectStackShown = true; // shut up
+ }
+ return;
}
+ textEditor.doSave(monitor);
}
@Override
public boolean isDirty() {
- try {
- return fTextEditor.isDirty();
- } catch (NullPointerException e) {
+ ITextEditor textEditor = fTextEditor;
+ if (textEditor == null) { // disconnected Editor - for example due to disposed
// This should not happen. Code added to handle the below bug.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=550336
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log = Platform.getLog(bundle);
- Status status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, null, e);
- log.log(status);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569286
+ if (disconnectStack != null && !disconnectStackShown) {
+ Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
+ ILog log = Platform.getLog(bundle);
+ disconnectStack.addSuppressed(new IllegalStateException("isDirty check after disconnect")); //$NON-NLS-1$
+ Status status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, disconnectStack.getMessage(),
+ disconnectStack);
+ log.log(status);
+ disconnectStackShown = true; // shut up
+ }
return false;
}
+ return textEditor.isDirty();
}
/*

Back to the top