Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-04-27 18:39:06 +0000
committerMichael Valenta2007-04-27 18:39:06 +0000
commitd61a43cf336ac3fb8fae73ca4b7dc04f6b5fdcb7 (patch)
tree991bad5c83ac0d70e679b80ef3c0f613c71b334a /bundles/org.eclipse.compare
parentf613b1f573aadd9ffd578ee34dc64cfedd9fe9e5 (diff)
downloadeclipse.platform.team-d61a43cf336ac3fb8fae73ca4b7dc04f6b5fdcb7.tar.gz
eclipse.platform.team-d61a43cf336ac3fb8fae73ca4b7dc04f6b5fdcb7.tar.xz
eclipse.platform.team-d61a43cf336ac3fb8fae73ca4b7dc04f6b5fdcb7.zip
Bug 184489 NPE when I open the compare editor
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java19
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java19
2 files changed, 26 insertions, 12 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index e59fa9bab..505e75ee8 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -424,7 +424,13 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
// Ensure that this method is only called once
Assert.isTrue(fSourceViewer == null);
fSourceViewer = viewer;
- internalSetDocument(viewer);
+ try {
+ internalSetDocument(viewer);
+ } catch (RuntimeException e) {
+ // The error may be due to a stale entry in the DocumentManager (see bug 184489)
+ clearCachedDocument();
+ throw e;
+ }
viewer.setEditable(isEditable);
// Verify changes if the document is editable
if (isEditable) {
@@ -674,6 +680,10 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
oldDoc.removeDocumentListener(this);
}
}
+ clearCachedDocument();
+ }
+
+ private void clearCachedDocument() {
// Finally, remove the document from the document manager
IDocument doc = DocumentManager.get(fElement);
if (doc != null)
@@ -734,7 +744,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
boolean hasSharedDocument(Object object) {
return (fElement == object &&
fDocumentProvider != null
- && fDocumentProvider.getDocument(getDocumentKey()) == DocumentManager.get(object));
+ && fDocumentProvider.getDocument(getDocumentKey()) != null);
}
public boolean flush() throws CoreException {
@@ -785,10 +795,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void resetDocument() {
// Need to remove the document from the manager before refreshing
// or the old document will still be found
- IDocument doc = DocumentManager.get(fElement);
- if (doc != null) {
- DocumentManager.remove(doc);
- }
+ clearCachedDocument();
// TODO: This is fine for now but may need to be revisited if a refresh is performed
// higher up as well (e.g. perhaps a refresh request that waits until after all parties
// have been notified).
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index e59fa9bab..505e75ee8 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -424,7 +424,13 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
// Ensure that this method is only called once
Assert.isTrue(fSourceViewer == null);
fSourceViewer = viewer;
- internalSetDocument(viewer);
+ try {
+ internalSetDocument(viewer);
+ } catch (RuntimeException e) {
+ // The error may be due to a stale entry in the DocumentManager (see bug 184489)
+ clearCachedDocument();
+ throw e;
+ }
viewer.setEditable(isEditable);
// Verify changes if the document is editable
if (isEditable) {
@@ -674,6 +680,10 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
oldDoc.removeDocumentListener(this);
}
}
+ clearCachedDocument();
+ }
+
+ private void clearCachedDocument() {
// Finally, remove the document from the document manager
IDocument doc = DocumentManager.get(fElement);
if (doc != null)
@@ -734,7 +744,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
boolean hasSharedDocument(Object object) {
return (fElement == object &&
fDocumentProvider != null
- && fDocumentProvider.getDocument(getDocumentKey()) == DocumentManager.get(object));
+ && fDocumentProvider.getDocument(getDocumentKey()) != null);
}
public boolean flush() throws CoreException {
@@ -785,10 +795,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void resetDocument() {
// Need to remove the document from the manager before refreshing
// or the old document will still be found
- IDocument doc = DocumentManager.get(fElement);
- if (doc != null) {
- DocumentManager.remove(doc);
- }
+ clearCachedDocument();
// TODO: This is fine for now but may need to be revisited if a refresh is performed
// higher up as well (e.g. perhaps a refresh request that waits until after all parties
// have been notified).

Back to the top