Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2017-02-07 17:48:32 -0500
committerSergey Prigogin2017-02-07 17:52:14 -0500
commit810257caee3494f596600cd3ebf869d874b5f0c5 (patch)
tree6899015ab2e7812867ba2d15f45d8a952e157a41
parent143f85b06e81e9ad842392fc3c4a6166394d8a56 (diff)
downloadorg.eclipse.cdt-810257caee3494f596600cd3ebf869d874b5f0c5.tar.gz
org.eclipse.cdt-810257caee3494f596600cd3ebf869d874b5f0c5.tar.xz
org.eclipse.cdt-810257caee3494f596600cd3ebf869d874b5f0c5.zip
Bug 511871 - CContentAssistProcessor.createContext may leak index lock
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java44
1 files changed, 25 insertions, 19 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
index 662662f050..3948214d9e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
@@ -266,29 +266,35 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
char activationChar = getActivationChar(viewer, offset);
CContentAssistInvocationContext context =
new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
- if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
- fReplacementAutoActivationCharacters.contains('.')) {
- IASTCompletionNode node = context.getCompletionNode();
- if (node != null) {
- IASTName[] names = node.getNames();
- if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
- IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
- IASTExpression ownerExpr = ref.getFieldOwner();
- IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(), SemanticUtil.TDEF);
- if (ownerExprType instanceof ICPPUnknownType) {
- ownerExprType = HeuristicResolver.resolveUnknownType((ICPPUnknownType) ownerExprType,
- names[0]);
- }
- if (ownerExprType instanceof IPointerType) {
- context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
+ try {
+ if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
+ fReplacementAutoActivationCharacters.contains('.')) {
+ IASTCompletionNode node = context.getCompletionNode();
+ if (node != null) {
+ IASTName[] names = node.getNames();
+ if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
+ IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
+ IASTExpression ownerExpr = ref.getFieldOwner();
+ IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(), SemanticUtil.TDEF);
+ if (ownerExprType instanceof ICPPUnknownType) {
+ ownerExprType = HeuristicResolver.resolveUnknownType((ICPPUnknownType) ownerExprType,
+ names[0]);
+ }
+ if (ownerExprType instanceof IPointerType) {
+ context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
+ }
}
}
+ if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
+ // Auto-replace, but not auto-content-assist - bug 344387.
+ context.dispose();
+ context = null;
+ }
}
- if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
- // Auto-replace, but not auto-content-assist - bug 344387.
+ } catch (RuntimeException | Error e) {
+ if (context != null)
context.dispose();
- context = null;
- }
+ throw e;
}
return context;

Back to the top