mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 233976: Deadlock in ASTProvider
This commit is contained in:
parent
12cc9fcc6a
commit
9fd60a6db8
1 changed files with 26 additions and 13 deletions
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
@ -19,6 +18,7 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IDocumentExtension4;
|
import org.eclipse.jface.text.IDocumentExtension4;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IPartListener2;
|
import org.eclipse.ui.IPartListener2;
|
||||||
import org.eclipse.ui.IWindowListener;
|
import org.eclipse.ui.IWindowListener;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
@ -283,20 +283,35 @@ public final class ASTProvider {
|
||||||
return;
|
return;
|
||||||
Assert.isTrue(cElement instanceof ITranslationUnit);
|
Assert.isTrue(cElement instanceof ITranslationUnit);
|
||||||
fCache.aboutToBeReconciled((ITranslationUnit)cElement);
|
fCache.aboutToBeReconciled((ITranslationUnit)cElement);
|
||||||
fTimeStamp= getCurrentModificationStamp();
|
updateModificationStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized long getCurrentModificationStamp() {
|
private boolean updateModificationStamp() {
|
||||||
long timeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
|
long timeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
|
||||||
|
ITextEditor textEditor= null;
|
||||||
|
synchronized (this) {
|
||||||
if (fActiveEditor instanceof ITextEditor) {
|
if (fActiveEditor instanceof ITextEditor) {
|
||||||
ITextEditor textEditor= (ITextEditor) fActiveEditor;
|
textEditor= (ITextEditor) fActiveEditor;
|
||||||
IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
|
timeStamp= fTimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (textEditor != null) {
|
||||||
|
IEditorInput editorInput= textEditor.getEditorInput();
|
||||||
|
IDocument document= textEditor.getDocumentProvider().getDocument(editorInput);
|
||||||
if (document instanceof IDocumentExtension4) {
|
if (document instanceof IDocumentExtension4) {
|
||||||
IDocumentExtension4 docExt= (IDocumentExtension4) document;
|
IDocumentExtension4 docExt= (IDocumentExtension4) document;
|
||||||
timeStamp= docExt.getModificationStamp();
|
long newTimeStamp= docExt.getModificationStamp();
|
||||||
|
if (newTimeStamp != timeStamp) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (fActiveEditor == textEditor && fTimeStamp == timeStamp) {
|
||||||
|
fTimeStamp= newTimeStamp;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return timeStamp;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -328,10 +343,8 @@ public final class ASTProvider {
|
||||||
if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
|
if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
long currentStamp= getCurrentModificationStamp();
|
if (isActive && updateModificationStamp()) {
|
||||||
if (isActive && fTimeStamp != currentStamp) {
|
|
||||||
fCache.disposeAST();
|
fCache.disposeAST();
|
||||||
fTimeStamp= currentStamp;
|
|
||||||
}
|
}
|
||||||
return fCache.runOnAST((ITranslationUnit)cElement, waitFlag != WAIT_NO, monitor, astRunnable);
|
return fCache.runOnAST((ITranslationUnit)cElement, waitFlag != WAIT_NO, monitor, astRunnable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue