mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix memory leak in TranslationUnitAnnotationModel
This commit is contained in:
parent
0b1d8acefd
commit
0bb4c8bb9a
2 changed files with 23 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
* Copyright (c) 2002, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -130,6 +130,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
problemRequestor= null;
|
||||||
DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this);
|
DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this);
|
||||||
op.runOperation(null);
|
op.runOperation(null);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 QNX Software Systems and others.
|
* Copyright (c) 2002, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -92,43 +92,46 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
static protected class ProblemAnnotation extends Annotation implements ICAnnotation {
|
static protected class ProblemAnnotation extends Annotation implements ICAnnotation {
|
||||||
private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
|
private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
|
||||||
|
|
||||||
private ITranslationUnit fTranslationUnit;
|
private final ITranslationUnit fTranslationUnit;
|
||||||
|
private final int fId;
|
||||||
|
private final boolean fIsProblem;
|
||||||
|
private final String[] fArguments;
|
||||||
|
private final String fMarkerType;
|
||||||
private List fOverlaids;
|
private List fOverlaids;
|
||||||
private IProblem fProblem;
|
|
||||||
|
|
||||||
public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
|
public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
|
||||||
fProblem= problem;
|
|
||||||
fTranslationUnit= tu;
|
fTranslationUnit= tu;
|
||||||
|
setText(problem.getMessage());
|
||||||
|
fId= problem.getID();
|
||||||
|
fIsProblem= problem.isError() || problem.isWarning();
|
||||||
|
fArguments= isProblem() ? problem.getArguments() : null;
|
||||||
setType(problem instanceof CoreSpellingProblem ?
|
setType(problem instanceof CoreSpellingProblem ?
|
||||||
SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
|
SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
|
||||||
}
|
if (problem instanceof IPersistableProblem)
|
||||||
|
fMarkerType= ((IPersistableProblem) problem).getMarkerType();
|
||||||
/*
|
else
|
||||||
* @see ICAnnotation#getMessage()
|
fMarkerType= null;
|
||||||
*/
|
|
||||||
public String getText() {
|
|
||||||
return fProblem.getMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see ICAnnotation#getArguments()
|
* @see ICAnnotation#getArguments()
|
||||||
*/
|
*/
|
||||||
public String[] getArguments() {
|
public String[] getArguments() {
|
||||||
return isProblem() ? fProblem.getArguments() : null;
|
return fArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see ICAnnotation#getId()
|
* @see ICAnnotation#getId()
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return fProblem.getID();
|
return fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see ICAnnotation#isProblem()
|
* @see ICAnnotation#isProblem()
|
||||||
*/
|
*/
|
||||||
public boolean isProblem() {
|
public boolean isProblem() {
|
||||||
return fProblem.isError() || fProblem.isWarning();
|
return fIsProblem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -182,12 +185,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getMarkerType()
|
* @see org.eclipsecjdt.internal.ui.editor.ICAnnotation#getMarkerType()
|
||||||
*/
|
*/
|
||||||
public String getMarkerType() {
|
public String getMarkerType() {
|
||||||
if (fProblem instanceof IPersistableProblem)
|
return fMarkerType;
|
||||||
return ((IPersistableProblem) fProblem).getMarkerType();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +269,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
fList.clear();
|
fList.clear();
|
||||||
|
fAnchor= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue